Slang::Otherwise

Slang to add 'otherwise' block to 'for' loops

NAME

Slang::Otherwise - Slang to add 'otherwise' block to 'for' loops

SYNOPSIS

This slang adds syntax for an otherwise block that will run if the for loop is not entered.

for dir.grep(*.basename.contains: 'xyx') -> $f {
    say "Found $f"
}
otherwise {
    say 'Got nothing'
}

CREDITS & NOTES

This code is shamelessly taken from a blog post by Damian Conway.

Damian's slang called the block else, but the post spawned some discussion about whether that is a good name, also taking into consideration that Python's for/else does something entirely different. I recall someone suggested otherwise, which is a good a name as any.

LICENCE

The Artistic License 2.0

See LICENSE file in the repository for the full license text.

Slang::Otherwise v0.0.1

Slang to add 'otherwise' block to 'for' loops

Authors

  • zef:elcaro

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • Slang::Otherwise

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.