Skip to content

Instantly share code, notes, and snippets.

@Teqqles
Created November 22, 2016 14:26
Show Gist options
  • Save Teqqles/f514800c09c61caa5006179079666f73 to your computer and use it in GitHub Desktop.
Save Teqqles/f514800c09c61caa5006179079666f73 to your computer and use it in GitHub Desktop.
How to create method/function aliases with Scala
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