-
-
Save abrongersma/3731283 to your computer and use it in GitHub Desktop.
def smiley(hash) | |
myhash = {"happy" => ":)"} | |
hash.each do |key, value| | |
end | |
myhash["happy"] | |
end |
def smiley(key)
if {:mood => "happy"}
":)"
elsif {:mood => "sad"}
":("
elsif {:mood => "weird"}
":|"
end
end
def smiley(key)
if {:mood => "happy"}
":)"
end
if {:mood => "sad"}
":("
end
if {:mood => "weird"}
":|"
end
end
/app/vendor/bundle/ruby/1.9.1/bundler/gems/rspec-core-72c7ac5a76cc/lib/rspec/core/configuration.rb:730:in load': /tmp/d20120916-28-ltvvg6/hashes/spec/happy-or-sad_spec.rb:2: syntax error, unexpected tASSOC, expecting keyword_then or ';' or '\n' (SyntaxError) if mood => happy ^ from /app/vendor/bundle/ruby/1.9.1/bundler/gems/rspec-core-72c7ac5a76cc/lib/rspec/core/configuration.rb:730:in
block in load_spec_files'
from /app/vendor/bundle/ruby/1.9.1/bundler/gems/rspec-core-72c7ac5a76cc/lib/rspec/core/configuration.rb:730:in map' from /app/vendor/bundle/ruby/1.9.1/bundler/gems/rspec-core-72c7ac5a76cc/lib/rspec/core/configuration.rb:730:in
load_spec_files'
from /app/vendor/bundle/ruby/1.9.1/bundler/gems/rspec-core-72c7ac5a76cc/lib/rspec/core/command_line.rb:22:in run' from /app/vendor/bundle/ruby/1.9.1/bundler/gems/rspec-core-72c7ac5a76cc/lib/rspec/core/runner.rb:69:in
run'
from /app/vendor/bundle/ruby/1.9.1/bundler/gems/rspec-core-72c7ac5a76cc/lib/rspec/core/runner.rb:10:in `block in autorun'
def smiley(hash)
myhash = {"happy" => ":)"}
myhash[hash[:mood]]
end
def smiley(hash)
myhash = {"happy" => ":)", "sad" => ":(", "weird" => ":|"}
myhash[hash[:mood]]
end
hash = {"mood" => "happy"}
hash["mood"]
== "happy"
Hash[ [ ["a", 100], ["b", 200] ] ]
def smiley(key)
if {:mood =>"happy"}
":)"
elsif {:mood => "sad"}
":("
elsif {:mood => "weird"}
":|"
end
end