Ahhh ok, got it. If that's the case yes, then it shall be modified by the function as well as return it :P
Hopefully this will be usefull for other MooTools pals On 2 ene, 17:48, Arian Stolwijk <[email protected]> wrote: > It returns the modified object, like Object.merge does, which could be > useful if you use this function to return values in a function. > > var foo = function(){ > var obj = {}; > // blah, do something with the object > return Object.setToPath(obj, 'a.b.c', 100); > > }; > On Sun, Jan 2, 2011 at 11:43 PM, Ciul <[email protected]> wrote: > > Hi Arian. > > > > > > > > > > > WOW you got it reduced by...a ton of lines :P very nice :) > > > It seems still working the same :) > > > By the way, I don't return the modified object since the function > > modifies it itself. I mean, the object passed is modified by the > > function itself. > > > That might be changed now that I think it... LOL > > > On 2 ene, 17:36, Arian Stolwijk <[email protected]> wrote: > > > I updated it a little: http://jsfiddle.net/uqcDR/3/ > > > > <http://jsfiddle.net/uqcDR/2/> > > > > Hope it still works fine, but that's why Tests/Specs were invented :) > > > > On Sun, Jan 2, 2011 at 11:12 PM, Ciul <[email protected]> wrote: > > > > Hi pals. > > > > > I've seen myself in many circunstances needing something to append or > > > > set values to an object in a given path got from a dynamic string. > > > > I mean, each time receive a different string from some function and > > > > then need to populate an object with values at the path given by that > > > > string. > > > > > I wrote a function that could be added to MooTools->More->ObjectExtras > > > > if MooTools developers think it worths it. > > > > > In fact I got kinda inspired from MooTools->More->ObjectExtras- > > > > >getFromPath to write it. Thanks for that :P > > > > > jsFiddle link: > > > >http://jsfiddle.net/Ciul/uqcDR/ > > > > > Note: Look at the javascript console, it will throw some warnings but > > > > you can see the results anyway. > > > > > Judge it by yourself and I'd appreaciate any feedback. > > > > > Best regards, > > > > Ciul.
