In C++ I can do this:
(condition ? sin : cos)(0.5);
or
typedef std::deque<int> T;
(T().*(condition ? &T::push_back : &T::push_front))(1);
What would be an equivalent of this in Ruby?
I know I can use send
or method
, but they allow me to call private
methods.
# String#puts and String#print are private
("".method condition ? :puts : :print).call