Hi!
Here is a short script excerpt I use. view shape rectangle size: 10; fillColor: [ :aMethod | aMethod isCovered ifTrue: [ Color lightRed ] ifFalse: [ Color white ]]. view nodes: (aClass methods sortedAs: #isCovered).
I feel the way the color is set is very verbose. The following are equivalent fillColor: { #isCovered -> #lightRed } fillColor: { [:m | m isCovered] -> #lightRed } fillColor: { #isCovered -> #lightRed . [:m | m isCovered not ] -> #white}
The white color could be the default color is no color is picked up.
In the script above, I also use #sortedAs: to sort my elements. I find this method quite handy. It is defined as an extension of Collection. It is more flexible than Jannik's #sortedBy: and Moose's #sorted:. #sortedAs operates on boolean as well.
Any opinion?
Cheers, Alexandre
what is sortedAs:
STf On Mar 7, 2010, at 3:38 PM, Alexandre Bergel wrote:
Hi!
Here is a short script excerpt I use. view shape rectangle size: 10; fillColor: [ :aMethod | aMethod isCovered ifTrue: [ Color lightRed ] ifFalse: [ Color white ]]. view nodes: (aClass methods sortedAs: #isCovered).
I feel the way the color is set is very verbose. The following are equivalent fillColor: { #isCovered -> #lightRed } fillColor: { [:m | m isCovered] -> #lightRed } fillColor: { #isCovered -> #lightRed . [:m | m isCovered not ] -> #white}
The white color could be the default color is no color is picked up.
In the script above, I also use #sortedAs: to sort my elements. I find this method quite handy. It is defined as an extension of Collection. It is more flexible than Jannik's #sortedBy: and Moose's #sorted:. #sortedAs operates on boolean as well.
Any opinion?
Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
I method that I wrote some times ago. It sorts collection in a fancy way.
Alexandre
On 7 Mar 2010, at 13:10, Stéphane Ducasse wrote:
what is sortedAs:
STf On Mar 7, 2010, at 3:38 PM, Alexandre Bergel wrote:
Hi!
Here is a short script excerpt I use. view shape rectangle size: 10; fillColor: [ :aMethod | aMethod isCovered ifTrue: [ Color lightRed ] ifFalse: [ Color white ]]. view nodes: (aClass methods sortedAs: #isCovered).
I feel the way the color is set is very verbose. The following are equivalent fillColor: { #isCovered -> #lightRed } fillColor: { [:m | m isCovered] -> #lightRed } fillColor: { #isCovered -> #lightRed . [:m | m isCovered not ] -> #white}
The white color could be the default color is no color is picked up.
In the script above, I also use #sortedAs: to sort my elements. I find this method quite handy. It is defined as an extension of Collection. It is more flexible than Jannik's #sortedBy: and Moose's #sorted:. #sortedAs operates on boolean as well.
Any opinion?
Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
ok but still send the code because right now I do not get it.
Stef
On Mar 7, 2010, at 5:37 PM, Alexandre Bergel wrote:
I method that I wrote some times ago. It sorts collection in a fancy way.
Alexandre
On 7 Mar 2010, at 13:10, Stéphane Ducasse wrote:
what is sortedAs:
STf On Mar 7, 2010, at 3:38 PM, Alexandre Bergel wrote:
Hi!
Here is a short script excerpt I use. view shape rectangle size: 10; fillColor: [ :aMethod | aMethod isCovered ifTrue: [ Color lightRed ] ifFalse: [ Color white ]]. view nodes: (aClass methods sortedAs: #isCovered).
I feel the way the color is set is very verbose. The following are equivalent fillColor: { #isCovered -> #lightRed } fillColor: { [:m | m isCovered] -> #lightRed } fillColor: { #isCovered -> #lightRed . [:m | m isCovered not ] -> #white}
The white color could be the default color is no color is picked up.
In the script above, I also use #sortedAs: to sort my elements. I find this method quite handy. It is defined as an extension of Collection. It is more flexible than Jannik's #sortedBy: and Moose's #sorted:. #sortedAs operates on boolean as well.
Any opinion?
Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Hi,
I agree that we need a convenience construct for expressing properties based on a condition, but I do not like the format you propose :).
In VW, we had the following method: RectangleShape>>ifTrue: conditionBlock fillColor: colorBlock | oldBlock | oldBlock := self fillColor ifNil: self defaultFillColor. ^self fillColor: [ :each | (conditionBlock mondrianValue: each) ifTrue: [ colorBlock ] ifFalse: [ oldBlock ]].
Your examples would look like:
shape rectangle ifTrue: #isCovered fillColor: #lightRed. shape rectangle ifTrue: [:m | m isCovered] fillColor: #lightRed. shape rectnagle fillColor: #white; ifTrue: #isCovered fillColor: #lightRed.
Now, I would just rename "ifTrue:fillColor:" to "when:fillColor:" or "if:fillColor:".
Cheers, Doru
On 7 Mar 2010, at 23:02, Stéphane Ducasse wrote:
ok but still send the code because right now I do not get it.
Stef
On Mar 7, 2010, at 5:37 PM, Alexandre Bergel wrote:
I method that I wrote some times ago. It sorts collection in a fancy way.
Alexandre
On 7 Mar 2010, at 13:10, Stéphane Ducasse wrote:
what is sortedAs:
STf On Mar 7, 2010, at 3:38 PM, Alexandre Bergel wrote:
Hi!
Here is a short script excerpt I use. view shape rectangle size: 10; fillColor: [ :aMethod | aMethod isCovered ifTrue: [ Color lightRed ] ifFalse: [ Color white ]]. view nodes: (aClass methods sortedAs: #isCovered).
I feel the way the color is set is very verbose. The following are equivalent fillColor: { #isCovered -> #lightRed } fillColor: { [:m | m isCovered] -> #lightRed } fillColor: { #isCovered -> #lightRed . [:m | m isCovered not ] -> #white}
The white color could be the default color is no color is picked up.
In the script above, I also use #sortedAs: to sort my elements. I find this method quite handy. It is defined as an extension of Collection. It is more flexible than Jannik's #sortedBy: and Moose's #sorted:. #sortedAs operates on boolean as well.
Any opinion?
Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com
"It's not how it is, it is how we see it."
Your examples would look like:
shape rectangle ifTrue: #isCovered fillColor: #lightRed. shape rectangle ifTrue: [:m | m isCovered] fillColor: #lightRed. shape rectnagle fillColor: #white; ifTrue: #isCovered fillColor: #lightRed.
A bit more verbose, but looks okay. I will implement this.
Cheers, Alexandre
On 7 Mar 2010, at 23:02, Stéphane Ducasse wrote:
ok but still send the code because right now I do not get it.
Stef
On Mar 7, 2010, at 5:37 PM, Alexandre Bergel wrote:
I method that I wrote some times ago. It sorts collection in a fancy way.
Alexandre
On 7 Mar 2010, at 13:10, Stéphane Ducasse wrote:
what is sortedAs:
STf On Mar 7, 2010, at 3:38 PM, Alexandre Bergel wrote:
Hi!
Here is a short script excerpt I use. view shape rectangle size: 10; fillColor: [ :aMethod | aMethod isCovered ifTrue: [ Color lightRed ] ifFalse: [ Color white ]]. view nodes: (aClass methods sortedAs: #isCovered).
I feel the way the color is set is very verbose. The following are equivalent fillColor: { #isCovered -> #lightRed } fillColor: { [:m | m isCovered] -> #lightRed } fillColor: { #isCovered -> #lightRed . [:m | m isCovered not ] -
#white}
The white color could be the default color is no color is picked up.
In the script above, I also use #sortedAs: to sort my elements. I find this method quite handy. It is defined as an extension of Collection. It is more flexible than Jannik's #sortedBy: and Moose's #sorted:. #sortedAs operates on boolean as well.
Any opinion?
Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com
"It's not how it is, it is how we see it."
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Your examples would look like:
shape rectangle ifTrue: #isCovered fillColor: #lightRed. shape rectangle ifTrue: [:m | m isCovered] fillColor: #lightRed. shape rectnagle fillColor: #white; ifTrue: #isCovered fillColor: #lightRed.
A bit more verbose, but looks okay.
It is only a tiny bit more verbose, but it is significantly more explicit :).
I will implement this.
Thanks, Doru
Cheers, Alexandre
On 7 Mar 2010, at 23:02, Stéphane Ducasse wrote:
ok but still send the code because right now I do not get it.
Stef
On Mar 7, 2010, at 5:37 PM, Alexandre Bergel wrote:
I method that I wrote some times ago. It sorts collection in a fancy way.
Alexandre
On 7 Mar 2010, at 13:10, Stéphane Ducasse wrote:
what is sortedAs:
STf On Mar 7, 2010, at 3:38 PM, Alexandre Bergel wrote:
Hi!
Here is a short script excerpt I use. view shape rectangle size: 10; fillColor: [ :aMethod | aMethod isCovered ifTrue: [ Color lightRed ] ifFalse: [ Color white ]]. view nodes: (aClass methods sortedAs: #isCovered).
I feel the way the color is set is very verbose. The following are equivalent fillColor: { #isCovered -> #lightRed } fillColor: { [:m | m isCovered] -> #lightRed } fillColor: { #isCovered -> #lightRed . [:m | m isCovered not ] - > #white}
The white color could be the default color is no color is picked up.
In the script above, I also use #sortedAs: to sort my elements. I find this method quite handy. It is defined as an extension of Collection. It is more flexible than Jannik's #sortedBy: and Moose's #sorted:. #sortedAs operates on boolean as well.
Any opinion?
Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com
"It's not how it is, it is how we see it."
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com
"Next time you see your life passing by, say 'hi' and get to know her."
RectangleShape>>ifTrue: conditionBlock fillColor: colorBlock | oldBlock | oldBlock := self fillColor ifNil: self defaultFillColor. ^self fillColor: [ :each | (conditionBlock mondrianValue: each) ifTrue: [ colorBlock ] ifFalse: [ oldBlock ]].
Shouldn't a "mondrianValue: each" be added after colorBlock and oldBlock ? I added: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= MOFilledShape>>if: conditionBlock fillColor: colorBlock | oldBlockOrValue | oldBlockOrValue := self fillColor ifNil: [ self defaultFillColor ]. ^self fillColor: [ :each | (conditionBlock moValue: each) ifTrue: [ colorBlock moValue: each ] ifFalse: [ oldBlockOrValue moValue: each ]]. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Added if:fillColor: and testConditionalColor in 388
Cheers, Alexandre
On 7 Mar 2010, at 23:02, Stéphane Ducasse wrote:
ok but still send the code because right now I do not get it.
Stef
On Mar 7, 2010, at 5:37 PM, Alexandre Bergel wrote:
I method that I wrote some times ago. It sorts collection in a fancy way.
Alexandre
On 7 Mar 2010, at 13:10, Stéphane Ducasse wrote:
what is sortedAs:
STf On Mar 7, 2010, at 3:38 PM, Alexandre Bergel wrote:
Hi!
Here is a short script excerpt I use. view shape rectangle size: 10; fillColor: [ :aMethod | aMethod isCovered ifTrue: [ Color lightRed ] ifFalse: [ Color white ]]. view nodes: (aClass methods sortedAs: #isCovered).
I feel the way the color is set is very verbose. The following are equivalent fillColor: { #isCovered -> #lightRed } fillColor: { [:m | m isCovered] -> #lightRed } fillColor: { #isCovered -> #lightRed . [:m | m isCovered not ] -
#white}
The white color could be the default color is no color is picked up.
In the script above, I also use #sortedAs: to sort my elements. I find this method quite handy. It is defined as an extension of Collection. It is more flexible than Jannik's #sortedBy: and Moose's #sorted:. #sortedAs operates on boolean as well.
Any opinion?
Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com
"It's not how it is, it is how we see it."
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Hi Alex,
Nice catch. Indeed, this is a bug. The method was actually used only for constants like Color white, so I never detected it :)
Cheers, Doru
On 8 Mar 2010, at 19:55, Alexandre Bergel wrote:
RectangleShape>>ifTrue: conditionBlock fillColor: colorBlock | oldBlock | oldBlock := self fillColor ifNil: self defaultFillColor. ^self fillColor: [ :each | (conditionBlock mondrianValue: each) ifTrue: [ colorBlock ] ifFalse: [ oldBlock ]].
Shouldn't a "mondrianValue: each" be added after colorBlock and oldBlock ? I added: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= MOFilledShape>>if: conditionBlock fillColor: colorBlock | oldBlockOrValue | oldBlockOrValue := self fillColor ifNil: [ self defaultFillColor ]. ^self fillColor: [ :each | (conditionBlock moValue: each) ifTrue: [ colorBlock moValue: each ] ifFalse: [ oldBlockOrValue moValue: each ]]. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Added if:fillColor: and testConditionalColor in 388
Cheers, Alexandre
On 7 Mar 2010, at 23:02, Stéphane Ducasse wrote:
ok but still send the code because right now I do not get it.
Stef
On Mar 7, 2010, at 5:37 PM, Alexandre Bergel wrote:
I method that I wrote some times ago. It sorts collection in a fancy way.
Alexandre
On 7 Mar 2010, at 13:10, Stéphane Ducasse wrote:
what is sortedAs:
STf On Mar 7, 2010, at 3:38 PM, Alexandre Bergel wrote:
Hi!
Here is a short script excerpt I use. view shape rectangle size: 10; fillColor: [ :aMethod | aMethod isCovered ifTrue: [ Color lightRed ] ifFalse: [ Color white ]]. view nodes: (aClass methods sortedAs: #isCovered).
I feel the way the color is set is very verbose. The following are equivalent fillColor: { #isCovered -> #lightRed } fillColor: { [:m | m isCovered] -> #lightRed } fillColor: { #isCovered -> #lightRed . [:m | m isCovered not ] - > #white}
The white color could be the default color is no color is picked up.
In the script above, I also use #sortedAs: to sort my elements. I find this method quite handy. It is defined as an extension of Collection. It is more flexible than Jannik's #sortedBy: and Moose's #sorted:. #sortedAs operates on boolean as well.
Any opinion?
Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com
"It's not how it is, it is how we see it."
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com
"We are all great at making mistakes."
The method is defined on Collection:
-=-=-=-=-=-=-=-=-=-=-=-= sortedAs: aSortBlockOrSymbol "Answer a SortedCollection whose elements are the elements of the receiver. The sort order is defined by the argument, aSortBlock."
| aSortedCollection aSortBlock | aSortedCollection := SortedCollection new: self size. aSortBlock := aSortBlockOrSymbol isSymbol ifTrue: [ [:a :b | |t1 t2| t1 := (a perform: aSortBlockOrSymbol). t2 := (b perform: aSortBlockOrSymbol). ((t1 isKindOf: Boolean) and: [t2 isKindOf: Boolean]) ifTrue: [ t1 ] ifFalse: [ t1 < t2 ] ] ] ifFalse: [ aSortBlockOrSymbol ]. aSortedCollection sortBlock: aSortBlock. aSortedCollection addAll: self. ^ aSortedCollection -=-=-=-=-=-=-=-=-=-=-=-=
the idea is to be able to easily sort objects. Often I would to separate object following a boolean property: #(1 2 3 4 5 6 7) sortedAs: #odd ==> a SortedCollection(1 7 3 5 6 2 4)
In the example I gave in the previous email, I want to have method covered before
Alexandre
On 7 Mar 2010, at 19:02, Stéphane Ducasse wrote:
ok but still send the code because right now I do not get it.
Stef
On Mar 7, 2010, at 5:37 PM, Alexandre Bergel wrote:
I method that I wrote some times ago. It sorts collection in a fancy way.
Alexandre
On 7 Mar 2010, at 13:10, Stéphane Ducasse wrote:
what is sortedAs:
STf On Mar 7, 2010, at 3:38 PM, Alexandre Bergel wrote:
Hi!
Here is a short script excerpt I use. view shape rectangle size: 10; fillColor: [ :aMethod | aMethod isCovered ifTrue: [ Color lightRed ] ifFalse: [ Color white ]]. view nodes: (aClass methods sortedAs: #isCovered).
I feel the way the color is set is very verbose. The following are equivalent fillColor: { #isCovered -> #lightRed } fillColor: { [:m | m isCovered] -> #lightRed } fillColor: { #isCovered -> #lightRed . [:m | m isCovered not ] -> #white}
The white color could be the default color is no color is picked up.
In the script above, I also use #sortedAs: to sort my elements. I find this method quite handy. It is defined as an extension of Collection. It is more flexible than Jannik's #sortedBy: and Moose's #sorted:. #sortedAs operates on boolean as well.
Any opinion?
Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev