Class: Object

Inherits:
BasicObject
Defined in:
lib/object_as_no_refinements.rb

Instance Method Summary collapse

Instance Method Details

#as {|_self| ... } ⇒ Object

call-seq:

   obj.as{|x|...}    -> obj

Yields self to the block, and then returns the return value of the block.
The primary purpose of this method is to transform a value in a method 
chain without breaking the chain.
1, 2, 3

.map {|x| x * x } .as {|array| array.reverse } .each {|x| puts x }

Yields:

  • (_self)

Yield Parameters:

  • _self (Object)

    the object that the method was called on



15
16
17
# File 'lib/object_as_no_refinements.rb', line 15

def as
  yield self
end