Ghi chú (Comment)
1. Single-line Comment
Phần tiêu đề “1. Single-line Comment”// This is a single-line commentlet name = "Swift" // Comment ở cuối dòng2. Multi-line Comment
Phần tiêu đề “2. Multi-line Comment”/*This is amulti-line comment*/
/* * Can be formatted * with asterisks */3. Nested Comments
Phần tiêu đề “3. Nested Comments”Swift hỗ trợ nested comments:
/*Outer comment/* Nested comment */Still in outer comment*/4. Documentation Comments
Phần tiêu đề “4. Documentation Comments”4.1. Single-line documentation
Phần tiêu đề “4.1. Single-line documentation”/// Tính tổng hai sốfunc sum(a: Int, b: Int) -> Int { return a + b}4.2. Multi-line documentation
Phần tiêu đề “4.2. Multi-line documentation”/** Tính tổng hai số
- Parameters: - a: Số thứ nhất - b: Số thứ hai
- Returns: Tổng của a và b */func sum(a: Int, b: Int) -> Int { return a + b}5. Markup trong Documentation
Phần tiêu đề “5. Markup trong Documentation”/** # Heading
This function calculates the sum.
## Usage Example let result = sum(a: 5, b: 3)
- Important: Parameters must be integers - Note: Returns an Int value - Warning: May overflow for large numbers
- Parameter a: First number - Parameter b: Second number - Returns: Sum of a and b */func sum(a: Int, b: Int) -> Int { return a + b}6. Quick Help Markup
Phần tiêu đề “6. Quick Help Markup”/** Validates email address
- Author: Your Name - Version: 1.0 - Since: iOS 15.0 */func validateEmail(_ email: String) -> Bool { // Implementation return true}📝 Tóm tắt
Phần tiêu đề “📝 Tóm tắt”//- Single-line comment/* */- Multi-line comment///- Single-line documentation/** */- Multi-line documentation- Hỗ trợ nested comments
- Markdown trong documentation