Skip to content

Instantly share code, notes, and snippets.

@robyurkowski
Created June 12, 2014 21:27
Show Gist options
  • Save robyurkowski/0438d46fdf055bf270f6 to your computer and use it in GitHub Desktop.
Save robyurkowski/0438d46fdf055bf270f6 to your computer and use it in GitHub Desktop.
array = %w(dog cat aardvark)
array.each {|animal| puts animal.upcase }
array.map! {|animal| animal.reverse }
array.select {|animal| animal.include? 'a' }
array.sort_by(&:length)
array << 'dog'
array.uniq!
hash = {cat: "meow", dog: "woof", aardvark: "sluuurp"}
hash.keys.join(" and ")
hash.collect {|k, v| "the #{k.to_s} says #{v}"}
class Donkey < Animal
attr_accessor :name
def initialize(name)
@name = name
end
end
my_donkey = Donkey.new "Ernesto"
my_donkey.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment