Created
May 24, 2012 13:57
-
-
Save igaiga/2781704 to your computer and use it in GitHub Desktop.
[[:alice, "ALICE"], [:bob, "BOB"]] を {:alice => "ALICE, :bob => "BOB"} へ変換するコードを書いてください。
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
# -*- 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