> This is all well and good but the document does not make
> this at all clear. I would not have fallen into this trap if
> it was documented well.

Point taken, Adam. The documentation could certainly use improvement on that
point.

> I also would never have expected that calling a find method on
> on anything would ever modify the thing that I was calling it on. 

Although .find() does modify jQuery's internal node list, I agree the verb
"find" doesn't usually imply modification. There is some irony that jQuery's
methods like .remove() and .empty() actually *don't* change the object's
internal node list--they only remove the nodes from the document tree. All
this needs to be addressed either by documentation or changes to the
behavior.

> In Ruby, it is a convention that distructive methods are appended
> with bang (!). So that var.replace(foo, bar) returns a new string
> with the appropriate replacments but var.replace!(foo, bar) modifies
> the value of var directly. Its unfortunate that this is not possible
> in javascript, although perhaps using something like me.find$()
> would be sufficiently indicative.

That's an interesting idea. Since $ has been done to death, perhaps it could
use a trailing underscore? I think that's the only remaining special
character left. Alternatively, it could use a trailing capital letter like X
to indicate it changed the object.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to