Skip to content

Instantly share code, notes, and snippets.

View emilyreese's full-sized avatar

Emily Claire Reese emilyreese

View GitHub Profile
  1. Le Lambeau, Philippe Lançon

  2. Leurs enfants après eux, Nicolas Mathieu

  3. An Absolutely Remarkable Thing, Hank Green

  4. What Happened, Hillary Rodham Clinton

  5. Inspired: How to Create Tech Products Customers Love, Marty Cagan

>> pastries = ['croissant', 'cake', 'pie']
>> pastries.each {|p| puts "GIVE ME ONE " + p.upcase + "!"}
=> GIVE ME ONE CROISSANT!
GIVE ME ONE CAKE!
GIVE ME ONE PIE!
# let's change the contents of || to something nonsensical
>> pastries.each {|armchair| puts "GIVE ME ONE " + armchair.upcase + "!"}
=> GIVE ME ONE CROISSANT!
class BakedGood
attr_reader :name
def initialize(name)
@name = name
end
end
>> french_pastry = BakedGood.new('croissant')
=> #<BakedGood:0x007f7f6c4616d8 @name="croissant">
# defining a hash
bakery = {
name: 'Véronique Mauclerc',
address: '83 rue Crimée',
nearest_metro_station: 'Laumière',
}
# indexing into the hash
>> bakery[:name]
=> "Véronique Mauclerc"
# OPTION 1
# defining the method
def bake(pastry)
p 'Currently baking ' + pastry
end
# calling the method
>> bake('muffin')
=> "Currently baking muffin"
contents_of_pastry_case = ['croissant', 'apple pie', 'blueberry muffin']
>> contents_of_pastry_case[0]
=> "croissant"
>> contents_of_pastry_case[1]
=> "apple pie"