31 Mar 2005 09:27
Re: Re: [groovy-dev] RE: Some enhanced methods for collection
FWIW there are a few methods around like toList() and toArray(), maybe we need a toSet()? I do quite like list as Set too (allowing folks to specify the exact Set implementation if they wish) On 30 Mar 2005, at 22:10, John Rose wrote: > On Mar 30, 2005, at 11:47, Dierk Koenig wrote: >> For the use of imperative verbs: how would this relate to >> - compact >> - unique >> - sort (hehe) >> what would be the non-imperative versions that returns the copy? > > I'm not saying that all of these merit fresh-copy versions, but they > could be named: > > list.compacted() > list.withCompaction() > list.copyCompact() > > list.sort() > list.sorted() > list.copySort() > list as SortedSet // this is nice and clear, but no duplicates allowed > list as SortedList // not a real type, although Smalltalk has it > > After doing a bunch of these examples, the "copyFrob" convention may > start looking superior. > > I do not like the name list.unique(), because the word is an > adjective, which makes the grammar unclear. > I prefer Common Lisp's very explicit verb phrase: > list.removeDuplicates(). > > -- John > > James ------- http://radio.weblogs.com/0112098/
RSS Feed