*dicts or hashes are passed by reference in Python and Ruby*
That's it!
Python example:
Output:
[{'a': 1}, {'a': 1}, {'a': 1}, {'a': 1}]
Ruby example:
Output:
[{"a"=>1}, {"a"=>1}, {"a"=>1}, {"a"=>1}]
Jul 11, 2009
Hashes and Dicts in Python and Ruby
Posted by
Igor
at
11:50 AM
Labels: programming, python, ruby
Subscribe to:
Post Comments (Atom)
disclaimer
Things written in this blog are my personal thoughts or points of view, and do not represent at all the position of my employer.
Content of this blog is:

Licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.

Licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.

3 comments:
No pretty output in Ruby... I have to work in my Ruby-jitsu :P
hi Igor,
to improve rubys example output you can do:
puts l.inspect
or
require 'pp'
...code...
pp l
done, thanks!
Post a Comment