Skip to content

[Cookbook] Shorthand Fn.new

Camilo edited this page Apr 29, 2021 · 1 revision

Ruby shows how can create a shorthand version of Fn.new using methods inside classes.

class Obj {
    fn(f) { f }
}

class Example is Obj {
    construct new() {
        var ok = fn {|test| System.print(test) }
        ok.call("hello")
    }
}

Example.new() // expect: hello