22853 Posts in 9936 Topics by 2804 members
General questions about getting started with SilverStripe that don't fit in any of the categories above.
|Go to End|
21 January 2013 at 1:55pm Last edited: 21 January 2013 1:55pm
Please have a look at this:
03 $myDataList = MyDataObject::get();
05 //option 1
06 $myDataList = $myDataList->Filter("MyField", 1);
09 //option 2
10 $myDataList->Filter("MyField", 1);
12 return $myDataList
14 // QUESTION: does option 1 return the same as 2? Is that something that is different between 3.0 and 3.1?
This is a really important question. My answer is that option 1 is not the same as option 2. This surprises me and does not seem intuitive.
I would love to hear some thoughts on this.
21 January 2013 at 9:27pm
You can think of DataLists as immutable. In 3.0, this wasn't always the case (but is in this one). This means that methods that alter the representation of the list (so things like filter, exclude and sort though not things that alter the data like add and remove) return new instances of the list without changing the current variable.
21 January 2013 at 10:12pm Last edited: 21 January 2013 10:15pm
Simon, thank you very much for the reply. Disappointing it is so unclear (not your answer, the API itself).
22 January 2013 at 9:22am
Thanks again Simon for your answer, also see: https://github.com/silverstripe/sapphire/pull/1020 for more information.
22 January 2013 at 9:39am
|Go to Top|