20 lines
		
	
	
		
			512 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			512 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| class World(pub name: String, pub color: String) end
 | |
| 
 | |
| fn getWorlds() -> List<World> = [
 | |
|     World('Mercury', 'Red'),
 | |
|     World('Earth', 'Blue'),
 | |
|     World('Jupiter', 'Orange')
 | |
| ]
 | |
| 
 | |
| fn findWorldByColor(worlds: List<World>, color: String) -> String
 | |
|     worlds.find { it -> it.color == color }
 | |
|         .map { it -> it.name }
 | |
|         .expect "No world has the given color ${color}"
 | |
| end
 | |
| 
 | |
| fn main()
 | |
|     let worlds = getWorlds()
 | |
|     let blueWorld = findWorldByColor(worlds, 'Blue')
 | |
|     println "Hello, ${blueWorld}!"
 | |
| end
 | 
