This file contains hidden or 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 revolutionize_industry | |
philosophize(thinker, ideas).each do |idea| | |
publish(idea) | |
end | |
end |
This file contains hidden or 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 philosophize(thinker, thoughts) | |
thinker = Philosopher(thinker) | |
Array(thoughts).map do |thought| | |
thinker.think(thought) | |
end | |
end | |
def Philosopher(param) | |
return param if param.kind_of? Philosopher | |
return Philosopher.find(param) if param.kind_of? Integer |
This file contains hidden or 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
Array(nil) # => [] | |
Array(1) # => [1] | |
Array([3]) # => [3] | |
class ArrayLikeThing | |
def to_a | |
[1, 2, 3] | |
end |
This file contains hidden or 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
[11] pry(Kernel):1> ls -m --grep=^[A-Z] | |
Kernel.methods: Array Complex Float Hash Integer Pathname Rational String |
This file contains hidden or 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 philosophize(thinker, thoughts) | |
raise ArgumentError unless thinker.is_a? Philosopher | |
Array(thoughts).map do |thought| | |
thinker.think(thought) | |
end | |
end |
This file contains hidden or 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 philosophize(thinker, thoughts) | |
raise ArgumentError unless thinker.is_a? Philosopher | |
thoughts = [thoughts] unless thoughts.kind_of? Array | |
thoughts.map do |thought| | |
thinker.think(thought) | |
end | |
end |
This file contains hidden or 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 philosophize(thinker, thoughts) | |
return unless thinker.is_a? Philosopher | |
thoughts = [thoughts] unless thoughts.kind_of? Array | |
thoughts.map do |thought| | |
thinker.think(thought) | |
end | |
end |
This file contains hidden or 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 revolutionize_industry | |
taken_ideas = philosophize(thinker, ideas) | |
if !taken_ideas.nil? | |
taken_ideas.each do |idea| | |
publish(idea) | |
end | |
end | |
end |
This file contains hidden or 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 philosophize(thinker, thoughts) | |
return unless thinker.is_a? Philosopher | |
if thoughts.kind_of? Array | |
thoughts.map { |thought| thinker.think(thought) } | |
else | |
thinker.think(thought) # => <thought ...> | |
end | |
end |
This file contains hidden or 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
[1,2,3] |