Why do you have `.Bool` on all of the `.e` tests?
A file or directory either exists or it doesn't. So `.e` always returns a
Bool.
So there is zero reason to try to coerce it to a Bool.
You can look at the return value of `.e`.
> say '.'.IO.can('e').head.signature
(IO::Path:D: *%_ --> Bool)
If you don't trust that, you can look at the source
https://github.com/rakudo/rakudo/blob/fc88b9c2d2e71ab7fa492a53f0f90847c945bfcd/src/core.c/IO/Path.pm6#L738-L740
method e(IO::Path:D: --> Bool:D) {
nqp::hllbool(Rakudo::Internals.FILETEST-E(self.absolute)) }
It says it returns a Bool. It even uses `nqp::hllbool` which coerces the
value to `Bool`.
One of the design ethos of Raku is to reduce busy-work.
That is work that you don't really need to do.
I really can't understand why you insist on doing that busy-work anyway.
On Sun, May 17, 2020 at 4:56 AM ToddAndMargo via perl6-users <
[email protected]> wrote:
> On 2020-05-17 00:52, ToddAndMargo via perl6-users wrote:
> > Hi All,
> >
> > Windows 7 & 10
> >
> > I want to know if a drive letter exists:
> >
> >
> > K:\Windows\NtUtil>df -kPT
> > Filesystem Type 1024-blocks Used Available Capacity
> > Mounted on
> > C:/Program Files/Git ntfs 40585620 15044068 25541552 38% /
> > D: udf 5294394 5294394 0 100% /d
> > E: ntfs 8188 3908 4280 48% /e
> > F: ntfs 10236 3908 6328 39% /f
> > J: smbfs 951048868 514547660 436501208 55% /j
> > K: smbfs 951048868 514547680 436501188 55% /k
> > L: smbfs 951048868 514547700 436501168 55% /l
> >
> > K:\Windows\NtUtil>dir e:
> > Volume in drive E is DRIVERS
> > Volume Serial Number is 44EB-5181
> >
> > Directory of E:\
> >
> > File Not Found
> >
> > This exists:
> > K:\Windows\NtUtil>raku -e "say 'H:'.IO.d.Bool;"
> > True
> >
> > This does not:
> > K:\Windows\NtUtil>raku -e "say 'Z:'.IO.d.Bool;"
> > True
> >
> >
> > Many thanks,
> > -T
> >
> >
>
> Follow up:
>
> Hi All,
>
> Prince213 on the chat line helped me figure this out.
>
> This is from my IO keeper:
>
> Drive (letter) exists (Windows only):
> use `IO.e.Bool`
>
> # forward slashes
> >raku -e "say 'X:/'.IO.e.Bool;"
> False
>
> >raku -e "say 'D:/'.IO.e.Bool;"
> True
>
> >raku -e "say 'd:/'.IO.e.Bool;"
> True
>
> >raku -e "say 'Z:/'.IO.e.Bool;"
> False
>
> # back slashes
> >raku -e "say 'd:\\'.IO.e.Bool;"
> True
>
> >raku -e "say Q[d:\].IO.e.Bool;"
> True
>
> >raku -e "say Q[z:\].IO.e.Bool;"
> False
>
>
> -T
>