ZnUrl>>#withPathSegments: Surprise

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

ZnUrl>>#withPathSegments: Surprise

Sean P. DeNigris
Administrator
I expected #withPathSegments: to return a copy with path segments replaced by the argument, but in fact they were added to the existing path. Just me?
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: ZnUrl>>#withPathSegments: Surprise

Sven Van Caekenberghe-2
I don't know.

If you see where it is used, you'll see it makes sense to add:

  '<a href="http://host.com:80'">http://host.com:80' asZnUrl / 'files' / 'readme.txt'

Where #/ is equivalent to #withPathSegments.

I do remember adding this especially for you ;-)

> On 08 Jul 2015, at 18:30, Sean P. DeNigris <[hidden email]> wrote:
>
> I expected #withPathSegments: to return a copy with path segments replaced by
> the argument, but in fact they were added to the existing path. Just me?
>
>
>
> -----
> Cheers,
> Sean
> --
> View this message in context: http://forum.world.st/ZnUrl-withPathSegments-Surprise-tp4836593.html
> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: ZnUrl>>#withPathSegments: Surprise

Sean P. DeNigris
Administrator
Sven Van Caekenberghe-2 wrote
I do remember adding this especially for you ;-)
Ha ha, yes I remember... the #/ is certainly useful. My question is just about the name #withPathSegments:. Maybe something like #withAddedPathSegments: might be clearer? Also, there is the #copyXyz convention used elsewhere in Pharo. Maybe #copyAddingPathSegments: for uniformity?
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: ZnUrl>>#withPathSegments: Surprise

Sven Van Caekenberghe-2

> On 08 Jul 2015, at 19:13, Sean P. DeNigris <[hidden email]> wrote:
>
> Sven Van Caekenberghe-2 wrote
>> I do remember adding this especially for you ;-)
>
> Ha ha, yes I remember... the #/ is certainly useful. My question is just
> about the name #withPathSegments:. Maybe something like
> #withAddedPathSegments: might be clearer? Also, there is the #copyXyz
> convention used elsewhere in Pharo. Maybe#copyAddingPathSegments: for
> uniformity?

Maybe, but where do you find proof for the #withX: meaning 'replace X in a copy of the receiver ' ? I mean, it does not strike me as confusing. Of course, the longer #copyAddingPathSegments: is long and clear.

> -----
> Cheers,
> Sean
> --
> View this message in context: http://forum.world.st/ZnUrl-withPathSegments-Surprise-tp4836593p4836596.html
> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: ZnUrl>>#withPathSegments: Surprise

Sean P. DeNigris
Administrator
Sven Van Caekenberghe-2 wrote
where do you find proof for the #withX: meaning 'replace X in a copy of the receiver ' ?
I guess from the collection #with:... messages that start from a fresh copy, but also quickly browsing the image, I see other such uses e.g. #withAngle:, #withNewSelection:, all of which return a new instance with the argument passing through to it independent of the original value.
Cheers,
Sean