[Pharo-project] bindWith: implementation missing
Hi All, I miss String>>bindWith:
bindWith: with: etc.
in Pharo. Is there a reason for that missing? Has anyone an implementation for me? I dont want to reinvent the wheel ;-) Greetings Sabine
Something like this ? bindWith: arg1    ^ self bindWithArguments: (OrderedCollection with: arg1) bindWith: arg1 with: arg2    | coll |    coll := OrderedCollection with: arg1 with: arg2.    ^ self bindWithArguments: coll bindWith: arg1 with: arg2 with: arg3    | coll |    coll := OrderedCollection       with: arg1       with: arg2       with: arg3.    ^ self bindWithArguments: coll bindWith: arg1 with: arg2 with: arg3 with: arg4    | coll |    coll := OrderedCollection       with: arg1       with: arg2       with: arg3       with: arg4.    ^ self bindWithArguments: coll bindWithArguments: aCollection    | newString end |    newString := self copy.    end := aCollection size.    end to: 1       by: -1       do: [:i | newString := newString copyReplaceAll: '%' , i printString with: (aCollection at: i)].    ^newString ----------------- Benoit St-Jean Yahoo! Messenger: bstjean A standpoint is an intellectual horizon of radius zero. (Albert Einstein)
________________________________ From: Sabine Knöfel <sabine.knoefel@gmail.com> To: pharo-project@lists.gforge.inria.fr Sent: Tuesday, July 10, 2012 10:49:51 AM Subject: [Pharo-project] bindWith: implementation missing
Hi All,
I miss String>>bindWith:
bindWith: with: etc.
in Pharo. Is there a reason for that missing? Has anyone an implementation for me? I dont want to reinvent the wheel ;-)
Greetings Sabine
Thank you, Benoit. Sabine On Tue, Jul 10, 2012 at 5:05 PM, Benoit St-Jean <bstjean@yahoo.com> wrote:
Something like this ?
bindWith: arg1 ^ self bindWithArguments: (OrderedCollection with: arg1)
bindWith: arg1 with: arg2 | coll | coll := OrderedCollection with: arg1 with: arg2. ^ self bindWithArguments: coll
bindWith: arg1 with: arg2 with: arg3 | coll | coll := OrderedCollection with: arg1 with: arg2 with: arg3. ^ self bindWithArguments: coll
bindWith: arg1 with: arg2 with: arg3 with: arg4 | coll | coll := OrderedCollection with: arg1 with: arg2 with: arg3 with: arg4. ^ self bindWithArguments: coll
bindWithArguments: aCollection
| newString end | newString := self copy. end := aCollection size. end to: 1 by: -1 do: [:i | newString := newString copyReplaceAll: '%' , i printString with: (aCollection at: i)]. ^newString
----------------- Benoit St-Jean Yahoo! Messenger: bstjean A standpoint is an intellectual horizon of radius zero. (Albert Einstein)
________________________________ From: Sabine Knöfel <sabine.knoefel@gmail.com> To: pharo-project@lists.gforge.inria.fr Sent: Tuesday, July 10, 2012 10:49:51 AM Subject: [Pharo-project] bindWith: implementation missing
Hi All,
I miss String>>bindWith:
bindWith: with: etc.
in Pharo. Is there a reason for that missing? Has anyone an implementation for me? I dont want to reinvent the wheel ;-)
Greetings Sabine
Hi sabine what is bindWith:? Stef On Jul 10, 2012, at 4:49 PM, Sabine Knöfel wrote:
Hi All,
I miss String>>bindWith:
bindWith: with: etc.
in Pharo. Is there a reason for that missing? Has anyone an implementation for me? I dont want to reinvent the wheel ;-)
Greetings Sabine
Hi Stef, it is a helper method to put some strings together. Instead of using commata, like this 'one: ','1',' two: ','2',' three: ','3' ==>> 'one: 1 two: 2 three: 3' you use String>>bindWith:with:with: 'one: %1 two: %2 three: %3' bindWith: '1' with: '2' with: '3' ==> 'one: 1 two: 2 three: 3' It is more readable (and writeable:-)) imho. I know this from ibm Smalltalk/VisualAge and as far as I remember, Visual works has it, too. Greetings Sabine On Wed, Jul 11, 2012 at 2:59 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Hi sabine
what is bindWith:?
Stef
On Jul 10, 2012, at 4:49 PM, Sabine Knöfel wrote:
Hi All,
I miss String>>bindWith:
bindWith: with: etc.
in Pharo. Is there a reason for that missing? Has anyone an implementation for me? I dont want to reinvent the wheel ;-)
Greetings Sabine
You can do 'one: {1} two: {2} three: {3}' format: {'1'. '2'. '3'} :) Ben On Jul 11, 2012, at 3:42 PM, Sabine Knöfel wrote:
Hi Stef,
it is a helper method to put some strings together. Instead of using commata, like this
'one: ','1',' two: ','2',' three: ','3' ==>> 'one: 1 two: 2 three: 3'
you use String>>bindWith:with:with:
'one: %1 two: %2 three: %3' bindWith: '1' with: '2' with: '3'
==> 'one: 1 two: 2 three: 3'
It is more readable (and writeable:-)) imho.
I know this from ibm Smalltalk/VisualAge and as far as I remember, Visual works has it, too.
Greetings Sabine
On Wed, Jul 11, 2012 at 2:59 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Hi sabine
what is bindWith:?
Stef
On Jul 10, 2012, at 4:49 PM, Sabine Knöfel wrote:
Hi All,
I miss String>>bindWith:
bindWith: with: etc.
in Pharo. Is there a reason for that missing? Has anyone an implementation for me? I dont want to reinvent the wheel ;-)
Greetings Sabine
Hi Ben, ah! thank you, I did not know that. Dynamic arrays are new for me coming from another smalltalk dialect. Greetings Sabine On Wed, Jul 11, 2012 at 3:46 PM, Benjamin <benjamin.vanryseghem.pharo@gmail.com> wrote:
You can do
'one: {1} two: {2} three: {3}' format: {'1'. '2'. '3'}
:) Ben
On Jul 11, 2012, at 3:42 PM, Sabine Knöfel wrote:
Hi Stef,
it is a helper method to put some strings together. Instead of using commata, like this
'one: ','1',' two: ','2',' three: ','3' ==>> 'one: 1 two: 2 three: 3'
you use String>>bindWith:with:with:
'one: %1 two: %2 three: %3' bindWith: '1' with: '2' with: '3'
==> 'one: 1 two: 2 three: 3'
It is more readable (and writeable:-)) imho.
I know this from ibm Smalltalk/VisualAge and as far as I remember, Visual works has it, too.
Greetings Sabine
On Wed, Jul 11, 2012 at 2:59 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Hi sabine
what is bindWith:?
Stef
On Jul 10, 2012, at 4:49 PM, Sabine Knöfel wrote:
Hi All,
I miss String>>bindWith:
bindWith: with: etc.
in Pharo. Is there a reason for that missing? Has anyone an implementation for me? I dont want to reinvent the wheel ;-)
Greetings Sabine
Ok thanks for the explanation. I never used it in VW. Stef On Jul 11, 2012, at 3:42 PM, Sabine Knöfel wrote:
Hi Stef,
it is a helper method to put some strings together. Instead of using commata, like this
'one: ','1',' two: ','2',' three: ','3' ==>> 'one: 1 two: 2 three: 3'
you use String>>bindWith:with:with:
'one: %1 two: %2 three: %3' bindWith: '1' with: '2' with: '3'
==> 'one: 1 two: 2 three: 3'
It is more readable (and writeable:-)) imho.
I know this from ibm Smalltalk/VisualAge and as far as I remember, Visual works has it, too.
Greetings Sabine
On Wed, Jul 11, 2012 at 2:59 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Hi sabine
what is bindWith:?
Stef
On Jul 10, 2012, at 4:49 PM, Sabine Knöfel wrote:
Hi All,
I miss String>>bindWith:
bindWith: with: etc.
in Pharo. Is there a reason for that missing? Has anyone an implementation for me? I dont want to reinvent the wheel ;-)
Greetings Sabine
participants (4)
-
Benjamin -
Benoit St-Jean -
Sabine Knöfel -
Stéphane Ducasse