[ create a new paste ] login | about

Link: http://codepad.org/HcmmPAgg    [ raw code | output | fork ]

Ruby, pasted on Jun 27:
# Technology
class Technology
  attr_accessor :val

  def initialize
    @val = 42
    yield self
  end
end

# MyClass2
class MyClass
  # @param [Integer] val
  # @return [NilClass]
  def a_method(val)
    puts val
  end

  # @return [NilClass]
  def b_method
    Technology.new do |technology|
      a_method technology.val
    end
  end
end

my_class = MyClass.new
my_class.b_method # => 42


Output:
1
42


Create a new paste based on this one


Comments: