Literal notation for Pathnames

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?

not possible because its allready uses for regexp

Hi,

2013/1/4 Intransition [email protected]

/"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 H.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs