Working with Hashes (2)
Exercise 8.1
Make a new file hashes_2-1.rb, and dd the following lines:
languages = {:de => 'German',:en => 'English',:es => 'Spanish',}dictionary = {:de => { :one => 'eins', :two => 'zwei', :three => 'drei' },:en => { :one => 'one', :two => 'two', :three => 'three' },:es => { :one => 'uno', :two => 'dos', :three => 'tres' }}
Now, at the end of the file, add code that prints out the following:
In German, eins means one, zwei means two, drei means three.In Spanish, uno means one, duo means two, tres means three.
Exercise 8.2
Now, in a new file hashes_2-2.rb, with the same hashes from above, add code that prints out the following table:
de eins zwei dreien one two threees uno dos tres
Exercise 8.3
Copy your file to a new file cp hashes_2-2.rb hashes_2-3.rb and change your code so that it aligns the table columns:
de eins zwei dreien one two threees uno dos tres
Exercise 8.4
Copy your file to a new file cp hashes_2-3.rb hashes_2-4.rb and change your code so that it adds delimiters:
| de | eins | zwei | drei || en | one | two | three || es | uno | dos | tres |
当前内容版权归 rubymonstas 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 rubymonstas .
