|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching * Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
Grouping the input parametersConsider this snippet: func add(a: int, b: int): int = a + b echo add(2, 3) # 5 Since the input parameters have the same type, they can be grouped: func add(a, b: int): int = a + b echo add(2, 3) # 5 Now both How to add another group?Groups are separated with a ';' (semicolon) on the formal parameter list: func add(a, b: int; msg: string): int = a + b echo add(2, 3, "add two numbers") # 5 Actually, it would also work with a ',' (comma) instead of the semicolon. However, I find that harder to read. |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |