I'm trying to pass min and then later max to a method, but it doesn't seem to work.
def worker(x)
[3,4].x
end
worker(min)
I'm trying to pass min and then later max to a method, but it doesn't seem to work.
def worker(x)
[3,4].x
end
worker(min)
Do you want call methods by name? Then, use Object#send
.
def worker(x)
[3,4].send(x)
end
worker(:min)
# => 3
worker(:max)
# => 4