|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching * Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
Case insensitive identifier namesIdentifiers (variable/procedure names) are case insensitive in Nim, with the exception of the first character. Identifiers start with a lowercase letter, while types' name start with an uppercase letter. But after the first character, identifiers are case insensitive, and the underscore ('_') charcater can be either used or omitted. let my_name = "Laci" echo my_name # Laci echo myName # Laci echo myname # Laci echo m_y_n_a_m_e # Laci #echo MyName # error Why? Let's say there is a library that uses the camelCase style. However, in your programs you prefer the snake_case style. You can continue using the snake_case style, the compiler will find what you refer to. import third_party_pkg # it has an isPalindrome() function let name = "anna" echo name.is_palindrome() # works echo name.isPalindrome() # also works What about the first character?The first character matters. type Dog = object name: string let dog = Dog(name: "Dogmeat") # here, dog and Dog are two different things echo dog # (name: "Dogmeat") |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |