J
Josh Cheek
[Note: parts of this message were removed to make it a legal post.]
Hi, how do you define your own typecaster?
Builtin examples
Array(1..5) # => [1, 2, 3, 4, 5]
Integer(5.2) # => 5
Float(5) # => 5.0
I would expect it to be something like this
class Foo
def self.()(*objs)
Foo.new
end
end
Foo(1)
But that isn't valid syntax, and I'm not sure what to look up to figure this
out.
Hi, how do you define your own typecaster?
Builtin examples
Array(1..5) # => [1, 2, 3, 4, 5]
Integer(5.2) # => 5
Float(5) # => 5.0
I would expect it to be something like this
class Foo
def self.()(*objs)
Foo.new
end
end
Foo(1)
But that isn't valid syntax, and I'm not sure what to look up to figure this
out.