From: Peter Marsh Date: 2007-04-25T00:29:23+09:00 Subject: Re: Cards Class @Everyone Thanks for the positive feedback/ideas :D Robert Dober wrote: > On 4/23/07, Peter Marsh wrote: >> Hi, I'm an utter newbie to Ruby (and OOP!) and I thought I'd share my >> very first project. It's nothing special - just a simple class that >> simulates a deck of cards, but I'd like to get your comments to see if >> there's anything I can do better (enjoy!): > This is indeed not a bad attempt at all, however ;) > > ... > > HTH > Robert There are a lot of things in your post that're really great and have helped develop my (still limited) knowledge of Ruby. I don't quite understand this, however: > Cards = %w{ Deuce Three Four Five ... > Suits = %w{ Spades Hearts Diamonds Clubs } From what I've been able to work out it converts everything between {} into a string and then sticks that all in an array that Cards or Suits points to. Is this correct? Also > @deck[@top_card] or raise "There are only 42 cards in the deck ;)" I understand what this means, but I'm unsure how to integrate this into my code. Thanks for your help! P.S. I implimented the whole '@top_card' system so that deck[] would not have to be refilled with numbers each time it was shuffled - I had worries about speed but perhaps in this case they were a bit to extreme. -- Posted via http://www.ruby-forum.com/.