Last active
August 29, 2015 14:06
-
-
Save commel/0e60bc4f2e627cf5b098 to your computer and use it in GitHub Desktop.
Function parameters in several languages
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
(defn handle [func text] | |
(func text) | |
) | |
(println (handle clojure.string/upper-case "hallo welt")) |
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
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); | |
} | |
} |
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
def handle(func, text) | |
func.call(text) | |
end | |
puts( handle( ->(a){ a.upcase }, "hallo welt") ) |
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
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