RosettaCodeData/Task/Reflection-List-methods/Sidef/reflection-list-methods.sidef

11 lines
304 B
Plaintext

class Example {
method foo { }
method bar(arg) { say "bar(#{arg})" }
}
var obj = Example()
say obj.methods.keys.sort #=> ["bar", "call", "foo", "new"]
var meth = obj.methods.item(:bar) # `LazyMethod` representation for `obj.bar()`
meth(123) # calls obj.bar()