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
| def take_a_number(deli, person) | |
| deli << person | |
| deli.length | |
| end | |
| def now_serving(deli) | |
| puts "Currently serving #{deli.first}" | |
| deli.shift | |
| 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
| holiday_supplies = { | |
| :winter => { | |
| :christmas => ["Lights", "Wreath"], | |
| :new_years => ["Party Hats"] | |
| }, | |
| :summer => { | |
| :forth_of_july => ["Fireworks", "BBQ"] | |
| }, | |
| :fall => { | |
| :thanksgiving => ["Turkey"] |
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
| def apple_picker(array) | |
| apples_etc = array.collect { |element| element if element == "apple"} | |
| apples_etc.compact | |
| end | |
| def apple_picker(array) | |
| array.select {|element| element == "apple"} | |
| end | |
| # select returns an array of the original elements that make block evaluate to true, while |
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
| def reverse_each_word(sentence) | |
| words = sentence.split | |
| back_words = words.collect { |word| word.reverse } | |
| back_words.join(" ") | |
| 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
| movie_collection = { "horror" => ["Kindergarten Cop", "Psycho", "Last House on the Left"], | |
| "comedy" => ["Beverly Hills Cop", "Jackass"], | |
| "fantasy" => ["The Hobbit", "Willow", "The Princess Bride"]} | |
| recipes = { "bolognese sauce" => ["olive oil", "onion", "garlic", "tomato", "basil", "oregano"], | |
| "omlette" => ["eggs", "milk", "cheese"], | |
| "chicken adobo" => ["chicken", "vinegar", "onions", "garlic", "ginger", "soy sauch"]} | |
| user_profiles = { "Jordan" => { "favorite colors" => ["red", "yellow", "blue"], | |
| "personal_essays" => ["essay 1", "essay 2", "essay 3"] }, |
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
| def my_each(array) | |
| empty = (array.length == 0) | |
| i = 0 | |
| while (i < array.length) && !empty | |
| 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
| subs = {"to" => "2", "two" => "2", "too" => "2", | |
| "for" => "4", "four" => "4", "be" => "b", | |
| "you" => "u", "at" => "@", "and" => "&"} | |
| def string_shortener(str, subs) | |
| punks = [" ", ".", "?", "!", ","] | |
| current_word = "" | |
| shortened_str = "" | |
| return str if str.length <= 140 |
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
| #1 | |
| def is_vowel_elsif?(letter) | |
| if letter == "a" | |
| true | |
| elsif letter == "e" | |
| true | |
| elsif letter == "i" | |
| true | |
| elsif letter == "o" | |
| true |
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
| def get_badge(name) | |
| "Hello, my name is #{name}." | |
| end | |
| def get_badges(names_arr) | |
| badges_arr = [] | |
| names_arr.each do |name| | |
| badges_arr << get_badge(name) | |
| end | |
| badges_arr |