[Pharo-project] Explicit return in []

Lukas Renggli renggli at gmail.com
Thu Sep 15 03:28:41 EDT 2011


>> > Q1 When are they absolutely required?
>>
>> Not needed, but convenient. JavaScript for example does't have them. Things are done differently (exceptions, return values, ...).
>
> do you have some examples how they do that?

For example, instead of #at:ifAbsent: the array/dictionary access in
JavaScript returns a special "undefined" object if the object is not
present. "undefined" is a distinct object, but it behaves similar to
"null" (nil).

Exceptions are rarely used in JavaScript. PrototypeJS uses (or used)
them for example to break and continue in enumerables
(http://www.prototypejs.org/api/enumerable/each).

Lukas

-- 
Lukas Renggli
www.lukas-renggli.ch




More information about the Pharo-dev mailing list