Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # def timer
- # start_time = Time.now
- # yield
- # puts "Elapsed time: #{Time.now - start_time}s"
- # end
- # # def timer2
- # # start_time = Time.now
- # # (1..8000000).to_a.each {|n|}
- # # puts "Elapsed time: #{Time.now - start_time}s"
- # # end
- # # result = timer do |message|
- # # puts message
- # # sleep(2)
- # # end
- # # puts result
- # puts "how many iterations"
- # count = gets.chomp.to_i
- # result = timer do
- # (1..count).to_a.each {|n|}
- # end
- # puts result
- def say_hello(first_name, last_name)
- full_name = "#{first_name} #{last_name}"
- puts yield(full_name) if block_given?
- end
- say_hello("Charles", "Brownson")
- say_hello("Johnny", "Hallyday") do |name|
- "Hi #{name}"
- end
Add Comment
Please, Sign In to add comment