Forked from alexjfisher/gist:4cad33baccd97c17fb43062eb35d30f7
Last active
September 24, 2016 11:03
-
-
Save elomatreb/6c306be48e2b55b0a2badee109af76ac to your computer and use it in GitHub Desktop.
This file contains 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
return hash.reduce({}) do |acc, kv| | |
acc[id + kv[0]] = { 'key' => kv[0], 'value' => kv[1] } | |
acc # You're explicitely returning acc so it used again by the next invocation of the block | |
end | |
######## | |
return hash.each_with_object({}) do |kv, acc| # Argument order is switched | |
acc[id + kv[0]] = { 'key' => kv[0], 'value' => kv[1] } | |
# no need to explicitely return | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment