Wednesday, December 13, 2006

Too many arguments

I was not able to find a method with a higher number of arguments
than Travis found
. But I once saw an image with long methods
for Collection(class)>>with: keyword's. They extended the class side
messes of Collection like this:


So you could write

OrderedCollection with: $H with: $E with: $L with: $L with: $O

I guess they didnt know about Collection(class)>>withAll: which allows
you to write:

OrderedCollection withAll: #($H $E $L $L $O)


kerrin said...

(Kerrin's Husband, Travis Griggs, said...)

I've added the 5 argument with: myself. Though I never really needed 6. Seems to be something magical about 5. What would be really cool of course is this solution. :)

Diego Fernández said...

The #with:with:with:with: methods are for convenience, in fact all of them use #withAll:
If with:with: is not declared in Collection to write something like this:
c := OrderedCollection
with: MyClass new
with: (MyOtherClass for: 'bla').

You must do something like this:
c := OrderecCollection new
add: MyClass new;
add: (MyOtherClass for: 'bla');

Or for an Array:
c := Array new: 2.
c at: 1 put: MyClass new.
c at: 2 put: (MyOtherClass for: 'bla').

Not a big difference, but is convenient. Remember that you can't create an Array like this:
#(MyClass new)
Because this gives an array with two symbols. Squeak has a special notation, I think that is #{} (but is not portable to other smalltalks)

Andres said...

Since strings are collections too, you can also write

OrderedCollection withAll: 'Hello'