Re: contains question

2017-06-12 Thread Will Coleda
On Mon, Jun 12, 2017 at 4:07 PM, Elizabeth Mattijsen  wrote:
>> On 12 Jun 2017, at 22:04, Will Coleda  wrote:
>> On Mon, Jun 12, 2017 at 5:17 AM, Francesco Rivetti  wrote:
>>> if you can:
>>>
>>> $s ~~ "foo"
>>> $s ~~ /foo/
>>>
>>> then wouldn't be good to have also:
>>>
>>> $s.contains("foo");
>>> $s.contains(/foo/);
>>
>> The latter is currently available as:
>>
>>> "foobar".match(/'foo'/);
>> 「foo」
>
> That’s not entirely true, as .contains returns a Bool:D, not a Match object.  
> It *could* be interesting to not have to build the entire Match object 
> somehow and just return a Bool:D in case of contains.
>
>
> Liz

Sorry, you're right, it's:

?"foobar".match(/'foo'/);


-- 
Will "Coke" Coleda


Re: contains question

2017-06-12 Thread Will Coleda
On Mon, Jun 12, 2017 at 5:17 AM, Francesco Rivetti  wrote:
> if you can:
>
> $s ~~ "foo"
> $s ~~ /foo/
>
> then wouldn't be good to have also:
>
> $s.contains("foo");
> $s.contains(/foo/);

The latter is currently available as:

> "foobar".match(/'foo'/);
「foo」


> IOW, overload .contains() with Str and Regex
>
> F
>
>
> On 06/12/2017 10:42 AM, Elizabeth Mattijsen wrote:
>>
>>
>>> On 12 Jun 2017, at 01:27, ToddAndMargo  wrote:
>>> perl6 -e 'my $x = "\t"; if $x !~~ /<[A..Z a..z 0..9]>/ {say "out"} else
>>> {say "in"}'
>>>
>>> Would this be easier to do with $x.contains?  Or would it
>>> be too worky?
>>
>>
>> .contains only takes a *single string* to look up.  So it is only useful
>> for checking whether “foo” exists in “foo bar”:
>>
>>say “foo bar”.contains(“foo”)
>>
>>
>>
>> Liz
>>
>



-- 
Will "Coke" Coleda


Re: contains question

2017-06-12 Thread ToddAndMargo

On 06/12/2017 01:42 AM, Elizabeth Mattijsen wrote:



On 12 Jun 2017, at 01:27, ToddAndMargo  wrote:
perl6 -e 'my $x = "\t"; if $x !~~ /<[A..Z a..z 0..9]>/ {say "out"} else {say 
"in"}'

Would this be easier to do with $x.contains?  Or would it
be too worky?


.contains only takes a *single string* to look up.  So it is only useful for 
checking whether “foo” exists in “foo bar”:

   say “foo bar”.contains(“foo”)



Liz



Thank you Liz!


--
~
When we ask for advice, we are usually looking for an accomplice.
   --  Charles Varlet de La Grange
~


Re: contains question

2017-06-12 Thread Elizabeth Mattijsen
Thinking about this...

> On 12 Jun 2017, at 11:17, Francesco Rivetti  wrote:
> 
> if you can:
> 
> $s ~~ "foo"
> $s ~~ /foo/
> 
> then wouldn't be good to have also:
> 
> $s.contains("foo");
> $s.contains(/foo/);
> 
> IOW, overload .contains() with Str and Regex
> 
> F
> 
> On 06/12/2017 10:42 AM, Elizabeth Mattijsen wrote:
>>> On 12 Jun 2017, at 01:27, ToddAndMargo  wrote:
>>> perl6 -e 'my $x = "\t"; if $x !~~ /<[A..Z a..z 0..9]>/ {say "out"} else 
>>> {say "in"}'
>>> 
>>> Would this be easier to do with $x.contains?  Or would it
>>> be too worky?
>> .contains only takes a *single string* to look up.  So it is only useful for 
>> checking whether “foo” exists in “foo bar”:
>>   say “foo bar”.contains(“foo”)
>> Liz


Re: contains question

2017-06-12 Thread Francesco Rivetti

if you can:

$s ~~ "foo"
$s ~~ /foo/

then wouldn't be good to have also:

$s.contains("foo");
$s.contains(/foo/);

IOW, overload .contains() with Str and Regex

F

On 06/12/2017 10:42 AM, Elizabeth Mattijsen wrote:



On 12 Jun 2017, at 01:27, ToddAndMargo  wrote:
perl6 -e 'my $x = "\t"; if $x !~~ /<[A..Z a..z 0..9]>/ {say "out"} else {say 
"in"}'

Would this be easier to do with $x.contains?  Or would it
be too worky?


.contains only takes a *single string* to look up.  So it is only useful for 
checking whether “foo” exists in “foo bar”:

   say “foo bar”.contains(“foo”)



Liz



Re: contains question

2017-06-12 Thread Elizabeth Mattijsen

> On 12 Jun 2017, at 01:27, ToddAndMargo  wrote:
> perl6 -e 'my $x = "\t"; if $x !~~ /<[A..Z a..z 0..9]>/ {say "out"} else {say 
> "in"}'
> 
> Would this be easier to do with $x.contains?  Or would it
> be too worky?

.contains only takes a *single string* to look up.  So it is only useful for 
checking whether “foo” exists in “foo bar”:

  say “foo bar”.contains(“foo”)



Liz