|name| { return "Hello " + name } # short version function hi = |name| -> "Hi " + name # main.golo module myApp import my.lib function main = |args| { let name = "Baby Groot" println(hello(name)) println(hi(name)) }
|name| { return "Hello " + name } # short version function hi = |name| -> "Hi " + name # main.golo module myApp import my.lib function main = |args| { let name = "Baby Groot" println(hello(name)) println(hi(name)) }
|name| { return "Hello " + name } # short version function hi = |name| -> "Hi " + name # main.golo module myApp import my.lib function main = |args| { let name = "Baby Groot" println(hello(name)) println(hi(name)) }
|name| { return "Hello " + name } # short version function hi = |name| -> "Hi " + name # main.golo module myApp import my.lib function main = |args| { let name = "Baby Groot" println(hello(name)) println(hi(name)) }
isEqualTo42 = |value| { case { when value is 42 { return " good" } when value > 42 { return " too big" } otherwise { return " too little" } } } println(isEqualTo42(42)) # good println(isEqualTo42(24)) # too little println(isEqualTo42(84)) # too big }
lastName } augment human { function hello = |this| { println(this: firstName() + ": Hello!") } function hello = |this, message| { println(this: firstName() + ": Hello! " + message) } } function main = |args| { let jane = human("Jane", "Doe") jane: hello() # Jane: Hello! jane: hello("How are you doing?") # Jane: Hello! How are you doing? }
lastName } augment human { function hello = |this| { println(this: firstName() + ": Hello!") } function hello = |this, message| { println(this: firstName() + ": Hello! " + message) } } function main = |args| { let jane = human("Jane", "Doe") jane: hello() # Jane: Hello! jane: hello("How are you doing?") # Jane: Hello! How are you doing? }
firstName, lastName } struct dog = { name } augmentation eat = { function eat = |this, something| -> println("I'm eating " + something) } augment human with eat augment dog with eat function main = |args| { let jane = human("Jane", "Doe") let cookie = dog("Cookie") jane: eat("") # I'm eating cookie: eat("") # I'm eating }