Call a function: Difference between revisions

m
→‎{{header|Kotlin}}: made the Kotlin example not use Java
(Added EasyLang implementation)
m (→‎{{header|Kotlin}}: made the Kotlin example not use Java)
Line 3,200:
=={{header|Kotlin}}==
In Kotlin parameters are always passed by value though, apart from the (unboxed) primitive types, the value passed is actually a reference to an object.
<syntaxhighlight lang="scalakotlin">//fun versionfun1() 1.0.6= println("No arguments")
 
fun fun1() = println("No arguments")
 
fun fun2(i: Int) = println("One argument = $i")
Line 3,218 ⟶ 3,216:
fun fun8(x: String) = { y: String -> x + " " + y }
 
fun main(args: Array<String>) {
fun1() // no arguments
fun2(2) // fixed number of arguments, one here
Line 3,228 ⟶ 3,226:
println(1 + fun6(4, ::fun5) + 3) // first class context within an expression
println(fun5(5)) // obtaining return value
println(Mathkotlin.math.round(2.5)) // no distinction between built-in and user-defined functions, though former usually have a receiver
fun1() // calling sub-routine which has a Unit return type by default
println(fun7(11)) // calling function with a return type of Double (here explicit but can be implicit)
Line 3,244 ⟶ 3,242:
20
25
2.0
3
No arguments
5.5
Hello world
</pre>
 
=={{header|Lambdatalk}}==
In lambdatalk functions are abstractions {lambda {args} body} whose behaviour is best explained as a part of such a complete expression {{lambda {args} body} values}.
32

edits