Re: Good solution for managing stylesheets

Rick Olson
Fri, 19 Aug 2005 22:49:09 -0000

> Jamis,
>
> Sorry to interject... What does the asterisk (*) in the
> stylesheet_link_tag method call do?

Disclaimer: read the programming ruby book for a better explanation than mine :)

You sometimes see methods with parameters like that (such as
stylesheet_link_tag).  This lets you pass in an unlimited number of
params, and the method treats it as one variable.

def my_method(*args)

my_method(1, 2, 3)

Now, let''s say you want to call my_method which takes an *arg.  If you
do this:

@numbers = [1,2,3]
my_method(@numbers)

It will treat @numbers as the first argument only.  So, do this:
my_method(*@numbers).

--
rick