Created
August 8, 2017 21:01
-
-
Save benhardy/b8ee7bf497cc6f6b928093b45bd18176 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 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