Skip to content

Instantly share code, notes, and snippets.

@commel
Last active August 29, 2015 14:06
Show Gist options
  • Save commel/0e60bc4f2e627cf5b098 to your computer and use it in GitHub Desktop.
Save commel/0e60bc4f2e627cf5b098 to your computer and use it in GitHub Desktop.
Function parameters in several languages
(defn handle [func text]
(func text)
)
(println (handle clojure.string/upper-case "hallo welt"))
class Main {
static function main() {
new Main();
}
public function new() {
trace(handle(function(a:String) return a.toUpperCase(), "hallo welt"));
}
function handle(func: String -> String, text: String) {
return func(text);
}
}
def handle(func, text)
func.call(text)
end
puts( handle( ->(a){ a.upcase }, "hallo welt") )
class Main {
println(handle(
(a:String) => a.toUpperCase(),
"hallo welt")
)
private def handle(func: String => String, text: String):String = func(text);
}
new Main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment