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
# 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" |
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
# https://gist.github.com/andersr/6936448 |
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
# 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 |
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
# https://gist.github.com/scottcreynolds/34fad120a2d930e7e843 |
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
# 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 | |
# ====================================== |
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
# 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) |
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
# Lab: https://gist.github.com/aviflombaum/e6e5478ab9f59430b94a | |
# holiday hashes | |
holiday_supplies = { | |
:winter => { | |
:christmas => ["Lights", "Wreath"], | |
:new_years => ["Party Hats"] | |
}, |
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
# each | |
def each(array) | |
i = 0 | |
until i == array.length do | |
yield(array[i]) | |
i+=1 | |
end | |
array | |
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
# Create a method, apple_picker, that will pick all the apples out of an array. Implement it with collect and then implement it with select. Write a sentence about how select differs from collect. | |
fruits = ["orange", "banana", "apple", "orange", "apple", "banana", "orange", "apple"] | |
#with collect | |
def apple_picker_collect(array) | |
array.collect do |array_element| | |
array_element if array_element == "apple" | |
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
my_deli_line = [] | |
def take_a_number(deli_line, customer_name) | |
deli_line << customer_name | |
end | |
def current_line(deli_line) | |
print "Current line: " | |
deli_line.each_with_index do |person_in_line, i| | |
print "#{i + 1}. #{person_in_line} " |