Skip to content

Instantly share code, notes, and snippets.

View andersr's full-sized avatar
😅
Focusing

Anders Ramsay andersr

😅
Focusing
View GitHub Profile
# each
def each(array)
i = 0
until i == array.length do
yield(array[i])
i+=1
end
array
end
# Lab: https://gist.github.com/aviflombaum/e6e5478ab9f59430b94a
# holiday hashes
holiday_supplies = {
:winter => {
:christmas => ["Lights", "Wreath"],
:new_years => ["Party Hats"]
},
# Lab: https://gist.github.com/aviflombaum/f88ecccce35678b51506
my_deli = []
def take_a_number(venue, name)
venue << name
venue.index(name) + 1 #or could do: venue.length
end
def now_serving(venue)
# Download this file:
# https://gist.github.com/scottcreynolds/ac1b5c8d96de0c91bf7c/download
# Run it from your terminal with:
# ruby ruby_phone_format.rb
# (Just make sure you are in the right directory)
# ======================================
# Ignore All This Code
# ======================================
# https://gist.github.com/scottcreynolds/34fad120a2d930e7e843
# https://gist.github.com/scottcreynolds/f4593763b8b2bd56a041
# https://gist.github.com/scottcreynolds/7cb951c65d2244eaf37e
# http://flatironschool.s3.amazonaws.com/library/books/learn-to-program_p3_0.zip
# http://flatironschool.s3.amazonaws.com/library/books/programming-ruby-1-9_p4_2.zip
# https://gist.github.com/andersr/6936448
# Let's go back to the exercise where we determined what is and isn't a vowel.
# With ruby, there's always more than one way to do something and get the same result.
# Assuming vowels a,e,i,o,u:
VOWELS = ["a","e","i","o","u"]
# Write a method that returns whether a given letter is a vowel, using if and elsif
def is_a_vowel?(letter)
if letter == "a"
fizz, buzz, fizz_buzz, no_buzz = [], [], [], []
(1..50).each do |n|
if (n % 3 == 0) && (n % 5 == 0)
fizz_buzz.push(n)
elsif n % 3 == 0
fizz.push(n)
elsif n % 5 == 0
buzz.push(n)
else
# Download this file:
# https://gist.github.com/aviflombaum/28534c5d69edd2439a7d/download
# Run it from your terminal with:
# ruby ruby.basics.rb
# (Just make sure you are in the right directory)
# ======================================
# Ignore All This Code
# ======================================