Forum: Ruby Literal notation for Pathnames

Posted by Thomas Sawyer (7rans)
on 2013-01-04 03:57
(Received via mailing list)
One thing I would like Ruby to have is a concise literal notation for
pathnames. So maybe Ruby could have a literal notation as follows:

    /foo/bar    #=> #<Pathname:/foo/bar>
    ./foo/bar   #=> #<Pathname:./foo/bar>
    ../foo/bar  #=> #<Pathname:../foo/bar>

and/or

    /"foo/bar"    #=> #<Pathname:/foo/bar>
    ./"foo/bar"   #=> #<Pathname:./foo/bar>
    ../"foo/bar"  #=> #<Pathname:../foo/bar>

So, `/`, `./` and `../` would be special keyword and/or unary operators 
for
creating Pathname object.

Thoughts?
Posted by Hans Mackowiak (hanmac)
on 2013-01-04 05:43
not possible because its allready uses for regexp
Posted by Heesob Park (phasis)
on 2013-01-04 07:39
(Received via mailing list)
Hi,

2013/1/4 Intransition <transfire@gmail.com>
>     /"foo/bar"    #=> #<Pathname:/foo/bar>
>     ./"foo/bar"   #=> #<Pathname:./foo/bar>
>     ../"foo/bar"  #=> #<Pathname:../foo/bar>
>
> So, `/`, `./` and `../` would be special keyword and/or unary operators
> for creating Pathname object.
>
> Thoughts?
>
>
There was a very similar feature request 7 months ago.
Refer to https://bugs.ruby-lang.org/issues/6507.

Regards,
Park Heesob
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.