Skip to content

Instantly share code, notes, and snippets.

@benhardy
Created August 8, 2017 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhardy/b8ee7bf497cc6f6b928093b45bd18176 to your computer and use it in GitHub Desktop.
Save benhardy/b8ee7bf497cc6f6b928093b45bd18176 to your computer and use it in GitHub Desktop.
# layout - kinda python-like.
# indents are multiples of 4 spaces, no tabs allowed, violations won't compile
# if something is indented from the line before, it's implied that it is part of
# the thing defined on the line before
# defining an interface
# when things are immutable, a property is no different to a no-arg function
Verified
verifications: Int
# implementation of an interface
User
is Verified
name: String
# composition
Account
delegate user: User
joined: Date
fib(n: Int): Int = if (n > 0) (n * fib(n - 1)) else 1
# instances
fred = User(verifications = 3, name = "Fred")
acct = Account(user = fred, joined = Date.today)
verifications = fred.verifications
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment