Constants Variable (ตัวแปร)
Last updated
// Good
let π = 3.14159
let 你好 = "你好世界"
let 🐶🐮 = "dogcow"
// Bad
let _test = "Hello World"
let 12words = "Name of wordings"
let +variable = 10// Print string
print("Hello, Swift!")
// Print with parameter
let name = "John"
print(name)
// Print combine both of string and parameter
print("Hello, \(name)! Welcome to Swift programming."// This is a single-line comment (English)
// นี่คือตัวอย่างคอมเมนต์บรรทัดเดียว (ภาษาไทย)
print("Hello, Swift!") // Prints a string to the console (แสดงข้อความในคอนโซล)
/*
This is a multi-line comment.
You can use it for longer explanations. (English)
นี่คือตัวอย่างคอมเมนต์หลายบรรทัด
สามารถใช้เพื่ออธิบายโค้ดยาว ๆ ได้ (ภาษาไทย)
*/
let name = "John" // Declare a variable to store a name (ประกาศตัวแปรเก็บชื่อ)
// Printing a message with a variable
// แสดงข้อความพร้อมตัวแปร
print("Hello, \(name)! Welcome to Swift programming.") let cat = "🐱"; print(cat)
// Prints "🐱"