This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
outerArray= [1,2,:toast,:cream,4] | |
outerArray.chunk{|outer_elem| outer_elem}.class | |
# => Enumerator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
outerArray.chunk{|outer_elem| outer_elem}.each{|inner_elem| p inner_elem} | |
# => [1, [1]] | |
# [2, [2]] | |
# [:toast, [:toast]] | |
# [:cream, [:cream]] | |
# [4, [4]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
outerArray.chunk{|outer_elem| outer_elem.class}.each{|inner_elem| p inner_elem} | |
# => [Fixnum, [1, 2]] | |
# [Symbol, [:toast, :cream]] | |
# [Fixnum, [4]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
outerArray.chunk{|outer_elem| outer_elem.is_a?(Symbol)}.each{|inner_elem| p inner_elem} | |
# => [false, [1, 2]] | |
# [true, [:toast, :cream]] | |
# [false, [4]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
outerArray.chunk{|outer_elem| outer_elem.is_a?(Symbol)}.each do |boolSymbol,inner_elem| | |
p inner_elem if boolSymbol | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def initialize(target_object) | |
@target = target_object | |
@messages = [] | |
... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#The following method call.. | |
foo.bar(1,2,3) { |blockity| blockity.block } | |
#... is equivalent to.. | |
foo.send(bar,1,2,3,{ |blockity| blockity.block }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def initialize(target_object) | |
@target = target_object | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def method_missing(method_name, *args, &block) | |
@target.send(method_name, *args, &block) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Constructor. Store 'object' in instance variable. | |
def initialize (target) | |
@target = target | |
end | |
... | |
#Method_missing sends the method that doesn't appear in the proxy. | |
def method_missing (method_name, *args, &block) | |
@target.send(method_name, *args, &block |
OlderNewer