suppose
var=“world”
I want to call a method called hello_world() using the variable var. How
to do that in ruby?
and what feature of programing is this called?suppose
var=“world”
I want to call a method called hello_world() using the variable var. How
to do that in ruby?
and what feature of programing is this called?
to be clear:
I want something like calling the method like :
hello_+$var+()
But in that case you’d rather use a method argument, of course:
def hello(x)
puts “hello #{x}”
end
hello(“world”)
hello is a method (or rather function but Ruby does not have functions
which are not associated with a particular object). x is the
argument. “#{…}” is string interpolation.
Kind regards
robert
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.