Skip to content

Instantly share code, notes, and snippets.

@igaiga
Created May 24, 2012 13:57
Show Gist options
  • Save igaiga/2781704 to your computer and use it in GitHub Desktop.
Save igaiga/2781704 to your computer and use it in GitHub Desktop.
[[:alice, "ALICE"], [:bob, "BOB"]] を {:alice => "ALICE, :bob => "BOB"} へ変換するコードを書いてください。
# -*- coding: utf-8 -*-
# [[:alice, "ALICE"], [:bob, "BOB"]] を
# {:alice => "ALICE, :bob => "BOB"} へ変換するコードを書いてください。
# この問題おそらく正答率低いはず。
array = [[:alice, "ALICE"], [:bob, "BOB"]]
h = {}
result = array.each do |i|
h[i[0]] = i[1]
end
p h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment