public
Created

Use scala high functions in JRuby!

  • Download Gist
high_function.scala
Scala
1 2 3
object HighFunction {
def foo(num : Int)(f : Int => Int) = f(num)
}
test.rb
Ruby
1 2 3 4
require 'java'
import 'HighFunction' # make sure HighFunction.class & HighFunction$.class are in your path
 
HighFunction.foo(10) { |n| n * 2 } #=> 20

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.