Ticket #270 (closed enhancement: fixed)

Opened 1 year ago

Last modified 1 year ago

modify methodcaller or add function to return a property from an object

Reported by: karl.norby [at] gmail.com Assigned to: somebody
Priority: normal Milestone: MochiKit 1.5
Component: component1 Version:
Severity: trivial Keywords:
Cc:

Description

Basically, this change would be a nice help with certain uses of map. If I wanted to get property "foo" out of a list of objects using map, I would have to do something like

map(function(obj){ return obj.foo; }, listOfObjs);

Hardly a trouble, but it would be a little nicer to be able to write something like

map(getProperty("foo"), listOfObjs);

instead. The function methodcaller does something similar, so it could be modified to attempt to return a property's value if it is not a function, but a function like getProperty would serve more uses.

Change History

08/28/07 02:11:59 changed by therve@gmail.com

  • status changed from new to closed.
  • resolution set to fixed.

You're lucky, if I understand correctly, this is exactly what Base.itemgetter does: http://mochikit.com/doc/html/MochiKit/Base.html#fn-itemgetter