Created
March 18, 2016 03:20
-
-
Save 25564/0a2671f5e05a8b3805a6 to your computer and use it in GitHub Desktop.
CODE NETWORK!
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
object Calculator extends App { | |
def multiply(a:Int, b:Int) = a * b | |
def minus(a:Int, b:Int) = a - b | |
def add(a:Int, b:Int) = a + b | |
def divide(a:Int, b:Int) = a / b | |
def execute(f: (Int, Int) => Int, a: Int, b: Int):Int = { //Functions are objects in Scala | |
f(a,b) | |
} | |
println(execute(add, 31, 11)) //Meaning of Life | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment