----- Original Message ----- From: "William Pietri" <william-news-383910 / scissor.com> Newsgroups: comp.lang.ruby To: "ruby-talk ML" <ruby-talk / ruby-lang.org> Sent: Friday, August 30, 2002 11:35 AM Subject: Re: Newbie converting brain from perl > > BTW There's nothing non-OO about arrays in Ruby. They're not like Java! > > Ah, I should have explained more what I meant. > > In OO analysis and design, you find groups of data that travel together and > call them objects. If I break a log line up into an array of fields > > ["Aug", "24", "12", "31", "01", "myhost", "sendmail", "12345", "foo"] > > and pass that around, that's not very OO because there is an implicit > structure that isn't expressed in my representation. Arrays are just a row > of things, and I know more about the log line than that. So I could use a > hash to represent the structure and the data together: > > { "month"=>"Aug", "day"=>"24", "hour"=>"12", [...] } > > Which is better, right? With the array if I added a field in the middle (say > syslog starts logging microseconds) then everything breaks. But with the > hash, it's more flexible. If you're storing only data (not methods), consider a Struct for this. Hal