Guest User

Untitled

a guest
Apr 26th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. /**
  2. * Functon takes integers x and y with a return type of Int
  3. */
  4. fun multiply(x:Int,y:Int):Int{
  5. return x * y
  6. }
  7. /** No need or braces when only one statement is necessary**/
  8.  
  9. fun add(x: Int, y: Int):Int = x + y
  10.  
  11. /** Kotlin will know that return type is Int**/
  12.  
  13. fun subtract(x: Int,y: Int) = x - y
  14.  
  15. /*Find the max of a and b.
  16. * Note here that if construct is an epression in Kotlin(returns a value)
  17. * unlike in Java
  18. */
  19.  
  20. fun max(a:Float,b:Float) = if(a>b) a else b
Add Comment
Please, Sign In to add comment