Re: contains booboo
On Wed, Dec 19, 2018 at 7:58 AM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > In the mean time, I will ue if $x.contains("b") && not $x.contains( "q" ) > On 12/18/18 4:13 PM, Ralph Mellor wrote, demonstrating he never misses > anything: > > $x.contains("b") && not $x.contains("q") > .oO ( Seems I'm missing some of Todd's sentences. ) .oO ( I blame it on late night answers. ) .oO ( It couldn't possibly be that I'm getting older because I've always been getting older. I've also always been into late night answers but I think the nights are getting tougher due to, er, climate change. Yeah, that's gotta be it .) I think I am pushing 102. > .oO ( Wow. That's old. ) .oO ( Devs seem to be coding at a much older age these days. ) .oO ( That couldn't possibly be because they're getting older because they've always been getting older. This must just be one of those positive effects of climate change. Yeah. that's gotta be it. ) -- raiph
Re: contains booboo
On Tue, Dec 18, 2018 at 10:49 PM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: Hi All, Where is my booboo? $ p6 'my$x="abcd"; if $x.contains("b" && not "q") {say "y"}else{say "n"};' n In the mean time, I will ue if $x.contains("b") && not $x.contains( "q" ) Many thanks, -T On 12/18/18 4:13 PM, Ralph Mellor wrote: .contains tests whether its invocant, treated as a string, contains its argument, treated as a string. The argument you've given to .contains is: "b" && not "q". That's not a string. Here's one option: my$x="abcd"; if $x.contains("b") && not $x.contains("q") {say "y"}else{say "n"}; Hi Ralph, That was my work around. The reason I asked the question was the following: $ p6 'my$x="abcd"; if $x.contains("b" & "d") {say "y"}else{say "n"};' y $ p6 'my$x="abcd"; if $x.contains("b" & "e") {say "y"}else{say "n"};' n So it seemed to me that the following should also work, which it does not: Should be "y" $ p6 'my$x="abcd"; if $x.contains("b" & not "e") {say "y"}else{say "n"};' n Should be "n" and it is $ p6 'my$x="abcd"; if $x.contains("b" & not "d") {say "y"}else{say "n"};' n I think maybe I am pushing the limits. Perl has 101 way of doing everything. It think I am pushing 102. -T
Re: contains booboo
.contains tests whether its invocant, treated as a string, contains its argument, treated as a string. The argument you've given to .contains is: "b" && not "q". That's not a string. Here's one option: my$x="abcd"; if $x.contains("b") && not $x.contains("q") {say "y"}else{say "n"}; On Tue, Dec 18, 2018 at 10:49 PM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > Hi All, > > Where is my booboo? > > $ p6 'my$x="abcd"; if $x.contains("b" && not "q") {say "y"}else{say "n"};' > > n > > > In the mean time, I will ue > if $x.contains("b") && not $x.contains( "q" ) > > > Many thanks, > -T > > -- > ~~ > When you say, "I wrote a program that > crashed Windows," people just stare at > you blankly and say, "Hey, I got those > with the system, for free." > -- Linus Torvalds > ~~ >