I'm not sold on this. I certainly see how it would be useful, given the "falsy" nature of 0 and false and all that, but:
* There isn't a compelling enough use case *outside the framework* that would warrant putting this function in the dollar namespace. And without a short name it wouldn't save you much typing. * Using a ternary requires a bit more typing, but I think it produces more readable code. The purpose of $D would not be immediately apparent to people who don't work with the internals of Prototype every day. Cheers, Andrew On Feb 19, 12:01 am, "Tobie Langel" <[EMAIL PROTECTED]> wrote: > Hi all, > > I find myself writing code like that the whole time: > > example = example === undefined ? null : example; > > We could imagine the following utility function: > > $default = function(value, default) { > return value === undefined ? default : value; > } > > So that the above could be shortened to: > > example = $default(example, null); > > We could even decide to shorten it to $d: > > example = $d(example, null); > > I'm not 100% sure I like it... so I'm submitting it here for > discussion before eventually posting a patch. > > Regards, > > Tobie --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---