Skip to content

Instantly share code, notes, and snippets.

locus1 = ["E","e"]
locus2 = ["A","A+","At","a"]
zombie_locus = ["prl", "n"]
real_genes = [
["G","g"],
["Cr","n"],
["D","d"],
["Ch","n"],
["prl","n"], //interacts with locus4; see notes
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
def revolutionize_industry
taken_ideas = philosophize(thinker, ideas)
if !taken_ideas.nil?
taken_ideas.each do |idea|
publish(idea)
end
end
end
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
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
def philosophize(thinker, thoughts)
raise ArgumentError unless thinker.is_a? Philosopher
Array(thoughts).map do |thought|
thinker.think(thought)
end
end
[11] pry(Kernel):1> ls -m --grep=^[A-Z]
Kernel.methods: Array Complex Float Hash Integer Pathname Rational String
Array(nil) # => []
Array(1) # => [1]
Array([3]) # => [3]
class ArrayLikeThing
def to_a
[1, 2, 3]
end
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