On Tue, Feb 12, 2013 at 9:26 PM, Joel Pearson <lists / ruby-forum.com> wrote:
> Thanks for the advice and examples, I'll see whether I can understand
> how the classes and methods work with each other there and set about
> experimenting with them.

I didn't put commenting in the gist.  If there's anything unclear feel
free to ask.

> Once thing which put me off generating a custom class "from scratch" is
> that Array appears to be equal to its content (I assume this is a
> language shortcut), but it seems "custom" objects' values have to be
> accessed via their accessors.
> I was hoping for some more succinct syntax than this sort of thing:
> puts [] #Array is so easy to create
> puts CustomObject.new([]).value #This looks clunky next to that

You can get quite close, for example you can do

def M(*a)
  YourCustomMatrix.new(a)
end

# use
M(1,2,3,4)

or

M = Object.new
def M.[](*a)
  YourCustomMatrix.new(a)
end

# use
M[1,2,3,4]

> I'd love to get accustomed proper OO thinking, but I'll inevitably make
> all the rookie mistakes in the process.

Yes, it will take time.  Mistakes are what you will learn from.  Given
that, I should probably shut up and let you make your personal
mistakes. :-)

> It's a lot to get used to all at
> once given that I've been using Ruby for less than a year, and I have no
> training other than helpful hints and googling. Thanks again for your
> patience.

You're welcome!

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/