RosettaCodeData/Task/Reflection-List-methods/Sidef/reflection-list-methods.sidef
2023-07-01 13:44:08 -04:00

10 lines
304 B
Text

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()