Skip to content

Instantly share code, notes, and snippets.

@hughfdjackson
Last active January 2, 2016 02:59
Show Gist options
  • Select an option

  • Save hughfdjackson/8240674 to your computer and use it in GitHub Desktop.

Select an option

Save hughfdjackson/8240674 to your computer and use it in GitHub Desktop.
// direct definition
def printPerson(person: { name: String }): Unit = {
println (person.name)
}
printPerson({ name: 'foo' }) // prints 'foo'
// with a structural alias
type Person = {
name: String
}
def printPerson(person: Person): Unit = {
println (person.name)
}
printPerson({ name: 'foo' }) // prints 'foo'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment