Comments ในภาษา Rust
เราสามารถทำ Comments ในภาษา Rust ได้ง่าย ๆ ด้วยวิธีการต่อไปนี้
ตัวอย่างการใช้ /// ในการ Comment คำสั่งหลายบรรทัด โดยต้อง Comment ทุกบรรทัดที่ต้องการ
ขอบคุณครับ
- ใช้ // ในการ Comment คำสั่งบรรทัดเดียว
- ใช้ /// ในการ Comment คำสั่งหลายบรรทัด โดยต้อง Comment ทุกบรรทัดที่ต้องการ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Line comments are anything after '//' and extend to the end of the line. | |
let x = 5; // this is also a line comment. | |
// If you have a long explanation for something, you can put line comments next | |
// to each other. Put a space between the // and your comment so that it's | |
// more readable. |
ตัวอย่างการใช้ /// ในการ Comment คำสั่งหลายบรรทัด โดยต้อง Comment ทุกบรรทัดที่ต้องการ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// `hello` is a function that prints a greeting that is personalized based on | |
/// the name given. | |
/// | |
/// # Arguments | |
/// | |
/// * `name` - The name of the person you'd like to greet. | |
/// | |
/// # Example | |
/// | |
/// ```rust | |
/// let name = "Steve"; | |
/// hello(name); // prints "Hello, Steve!" | |
/// ``` | |
fn hello(name: &str) { | |
println!("Hello, {}!", name); | |
} |
ความคิดเห็น
แสดงความคิดเห็น