From yesterday's Ruby course - a whole set of new examples on Ruby collections - arrays (which are ordered lists) and hashes (which are unordered). In other words, you look somethng up in an array by its position number, whereas you look something up in a hash based on its unique key, and the way it's implemented, you cannot sort those keys - if you try, you get an array or arrays of two elements returned!
[example] - Sorting an array and iterating through it in various ways
[example] - Using an anonymous array to swap over two variables easily
[exampe] - Combining arrays with "and" and "or"
[example] - sorting a hash - (you can't, but this shows how to get the same effective result!)
[example] - multidimensional structures in Ruby - a hash or arrays in this case
Here are some other examples from yesterday too - string handling and exceptions:
[example] - lots of ways of defining and handling strings
[example] - cleaning up strings of text that are user input using string methods and regular expressions
[example] Using a constant to turn debug mode on and off - also a very good example of reading from and processing a file in Ruby
(written 2010-02-03 07:28:50)
Associated topics are indexed under
R107 - Collections (Arrays and Hashes) in Ruby [2618] What are Ruby Symbols? - (2010-02-02)
[2606] Sorting arrays and hashes in Ruby - (2010-01-30)
[2291] Collection objects (array and hash) in Ruby - (2009-07-16)
[991] Adding a member to a Hash in Ruby - (2006-12-16)
R109 - Ruby - Strings and Regular Expressions [2623] Object Oriented Ruby - new examples - (2010-02-03)
[2614] Neatly formatting results into a table - (2010-02-01)
[2608] Search and replace in Ruby - Ruby Regular Expressions - (2010-01-31)
[2295] The dog is not in trouble - (2009-07-17)
[2293] Regular Expressions in Ruby - (2009-07-16)
[1891] Ruby to access web services - (2008-11-16)
[1887] Ruby Programming Course - Saturday and Sunday - (2008-11-16)
[1875] What are exceptions - Python based answer - (2008-11-08)
[1588] String interpretation in Ruby - (2008-03-21)
[1305] Regular expressions made easy - building from components - (2007-08-16)
[1195] Regular Express Primer - (2007-05-20)
[987] Ruby v Perl - interpollating variables - (2006-12-15)
[986] puts - opposite of chomp in Ruby - (2006-12-15)
[970] String duplication - x in Perl, * in Python and Ruby - (2006-12-07)
R111 - Ruby - Exceptions. [2622] Handling unusual and error conditions - exceptions - (2010-02-03)
[2620] Direct access to object variable (attributes) in Ruby - (2010-02-02)
[2615] String to number conversion with error trapping in Ruby - (2010-02-01)
R118 - Ruby Sources and Resources [2610] Cheat Sheet - what do you need for Ruby on Rails? - (2010-01-31)
[550] 2006 - Making business a pleasure - (2006-01-01)
R106 - Input and Output in Ruby [2290] Opening and reading files - the ruby fundamentals - (2009-07-16)
[1587] Some Ruby programming examples from our course - (2008-03-21)
Some other Articles
Both feet on the same pavementSkyline and looking up in LondonRuby collections and strings - some new examplesPassing code to procedures and yield in RubyComparing floating point numbers - a word of caution and a solutionDefining a static method - Java, Python and Ruby