ages = [28, 32, 42, 64]
ages.map { |x| x * 2 }
ages.each { |age| puts "Age is: #{age}" }
-
What is the result of the
ages.map
call? What aboutages.each
? -
Is
x
in scope duringages.each
?
days = { monday: 'energized',
tuesday: 'excited',
wednesday: 'resilient',
thursday: 'exhausted',
friday: 'drinking' }
def my_example(week)
day = week.keys.sample
feel = week[day]
# feel = week.values.sample
print_feels(feel)
end
def print_feels(stuff)
puts "Today I'm feeling quite: #{stuff}"
end
my_example(days)
- What is the value of stuff in a call to
print_feels
?
-
Where are instance variables visible/in scope?
-
What is the purpose of unit tests?
-
Can we call methods on a class anywhere we have an instance of that class?