More Related Content
Similar to Week 4 unit3 (chapter 4-5) - function (20)
More from aj.mapling (10)
Week 4 unit3 (chapter 4-5) - function
- 5. ฟังก์ชัน
(Function)
5 Functions: Optional Positional Parameters
String prompt(String text, [int count]) {
if (count == null) {
count = 1;
}
for (int i = 0; i < count; i++) {
print(text);
}
}
void main() {
prompt("Your name:", 3);
prompt("Your Cat:");
}
- 6. ฟังก์ชัน
(Function)
6 Functions: Optional Named Parameters
String prompt(String text, [int count]) {
if (count == null) {
count = 1;
}
for (int i = 0; i < count; i++) {
print(text);
}
}
void main() {
prompt("Your name:", count:3);
prompt("Your Cat:");
}