[11:50:21] <lizmat> you don.t need the .Bool, .e already returns a Bool [11:53:07] <ToddAndMargo> sometimes IO.someletter returns True of Fail, not False. Tacking .Bool on the end, means I don't have to remember which ones [11:57:23] <ToddAndMargo> True or Fail. Typo [11:58:21] <lizmat> A Failure is always false [12:03:02] <ToddAndMargo> A Fail is a lot more than that. here is an example: >raku -e "say Q[z:\].IO.d;"Failed to find 'Z:\' while trying to do '.d' in block <unit> at -e line 1 [12:04:16] <ToddAndMargo> I use .bool at the end because I only want back a yes or no answer. And I certainly don't want it to crash. Always using .Bool keeps me out of trouble [12:19:21] <lizmat> say "directory foo exists" if "foo".IO.d [12:19:49] <lizmat> you don't have to worry about Failure then, which is the point of Failure to begin with [12:23:33] <ToddAndMargo> That is `if` converting the `X::IO::DoesNotExist` clutter into False for me. I never know when that will happen and when it won't, so tacking .Bool at the end keeps me out of trouble. I am not a purest here. I do not mind seeing .Bool at the end. It also tells me I will be seeing a Boolean. [12:28:42] <ToddAndMargo> bye bye for now. Thank you all for the tips!
> On 17 May 2020, at 12:36, Peter Pentchev <r...@ringlet.net> wrote: > > On Sun, May 17, 2020 at 03:01:34AM -0700, ToddAndMargo via perl6-users wrote: >> On 2020-05-17 02:30, Peter Pentchev wrote: >>> You said that you would tack Bool at the end in "if" statements, too. >> >> Hi Peter, >> >> No wonder. I do not remember saying that, but I could >> have. My `if` statements look like: >> >> if not "%Options<Path>".IO.d.Bool { >> say "Creating %Options<Path>"; >> mkdir( %Options<Path>", 0o777 ); >> } >> >> I definitely do not tack .Bool onto the end >> of my `if` statements. > > Uh. That's exactly what you're doing. You do *not* need the .Bool > there at the end. The "not" makes Raku convert whatever is there > to a boolean, so the .Bool is implicit. And if you were to check > the other way, if you had "if $foo.IO.d { ... }", then the "if" > makes Raku convert whatever is there to a boolean, so the .Bool is > implicit. You do not need to put the .Bool in an "if" or a "while" > statement. > > G'luck, > Peter > > -- > Peter Pentchev r...@ringlet.net r...@debian.org p...@storpool.com > PGP key: http://people.FreeBSD.org/~roam/roam.key.asc > Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13