Created
November 22, 2016 14:26
-
-
Save Teqqles/f514800c09c61caa5006179079666f73 to your computer and use it in GitHub Desktop.
How to create method/function aliases with Scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sheep(name: String, age: Int) = { println(name + " is aged " + age)} | |
// error, the compiler cannot determine what you want to do | |
//val badger = sheep | |
val cow = sheep(_,_) | |
val dog = sheep _ | |
sheep("Dolly", 10) | |
cow("Daisy", 5) | |
dog("Rover", 8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment