Passing method to method

class HighLowGame

  attr_accessor :randno, :guess



  def generateRandomNumber
        randno = rand(99)
        return randno
  end

  def getUserInput
          puts "Enter your guess"
          guess = gets.chomp.to_i

          return guess
  end

  def getResult(getUserInput())
        if guess < randno
           puts "#{guess } is lower than Magic Number"
        elsif guess > randno
           puts "#{guess} is higher than Magic Number"

        else  guess == randno
           puts "You are right!"
        end
  end

end

    suresh = HighLowGame.new
    suresh.getUserInput
    suresh.getResult(getUserInput())

Is it possible to pass method to methods?
I tried googling most of it is passing block to methods.

Suresh Ilankovan wrote in post #1185415:

Is it possible to pass method to methods?
I tried googling most of it is passing block to methods.

A) a method can be call by his name :

irb>class A
def b() p “b” end
def c(x,y) p “c #{x} #{y}” end
end

irb>A.new.send(“b”)
“b”
=> “b”
irb> A.new.send(“c”,1,2)
“c 1 2”
=> “c 1 2”

B) you can get method’s object and use it :

irb> x=A.new.method(“b”)
=> #<Method: A#b>
irb> x.call()
“b”
=> “b”
irb>

Regis d’Aubarede wrote in post #1185420:

irb>A.new.send(“b”)

For safety, I would recommend to use public_send instead of send, unless
you know what you are doing. When using send, you would also execute
private methods without getting any warning.