The typical way to make arguments to methods optional is to set a default value. See the example of your 'resize' method reworked. (Of course, you may want to have checks to make sure the passed value is an Integer, but I digress.)
If you have required arguments, then you don't set default values for them and then check that they are not nil (since if the method is called without passed arguments, the arguments will be assumed to be nil).
The other way is as you discovered: use the '*args' form. Then just check for the locations as needed or assign the extra args en masse.
Main Topics
Browse All Topics





by: isuhendroPosted on 2009-07-26 at 19:39:44ID: 24948578
I found out that above was caused by * symbol the precede args argument. After removing *, then it back to normal. But then how can i specify OPTIONAL argument in this case?