From: "Brian A." Date: 2008-11-28T12:29:40+09:00 Subject: Re: Noob: Code review my first tutorial homework assignment? Robert Dober wrote: > On Thu, Nov 27, 2008 at 8:46 PM, Brian A. > wrote: > >> yield(parameters, current_month) > A: 2 > Q: How many paramaters do you pass into the block > >> my_instance.my_own_ruby_method("alpha", "beta"){|s|puts s} > A: 1 > Q: I am sure you know it by now. > Cheers > Robert > -- > Ne baisse jamais la t�te, tu ne verrais plus les �toiles. > > Robert Dober ;) Thank you for the help. Does this look better? It runs with no error and seems to make sense to me... Any input is appreciated: ================================================================================= # Create a class called MyOwnRubyClass class MyOwnRubyClass # define a method called my_own_ruby_method # method receives two parameters called my_parameter and your_paramter def my_own_ruby_method(my_parameter, your_parameter, current_month) # method prints our current time using Time.now yield(Time.now) # 1) The method then invokes yield(my_parameter, your parameter, current_month) # 2) The current_month, is an integer value representing current month of the year, # for example, for the current month of "June", the current_month should be 6. # 3) The current_month value needs to computed in your program. # For example, if you are running the same program during July, it should be set to 7. # (In other words, you cannot pass hard-coded value in your program ) yield(my_parameter, your_parameter, current_month) end end my_instance = MyOwnRubyClass.new current_month = Date.today.month my_instance.my_own_ruby_method("alpha", "beta", Date.today.month){|arg1, arg2, arg3| puts "#{arg1} #{arg2} #{arg3}"} -- Posted via http://www.ruby-forum.com/.