perl6 -e 'say "abc".index("z") =:= Nil  ?? "False" !! "True"'

-e runs the script from the CL
https://github.com/rakudo/rakudo/wiki/Running-rakudo-from-the-command-line
"abc" is on front (but it could be in the same way)
index return Nil if it does not found (more logical than -1)
https://docs.perl6.org/routine/index; it's a constant, so you have to use
=:= to check for equality. https://docs.perl6.org/routine/=:=
??!! is the ternary operator in Perl 6
https://docs.perl6.org/language/operators#index-entry-operator_ternary-ternary_operator


JJ
PS: ObStackOverflow plug.

Reply via email to