Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gfldex/perl6-operator-defined-alternation
Provides a ?? !! equivalent that tests for definedness instread of trueness.
https://github.com/gfldex/perl6-operator-defined-alternation
Last synced: 13 days ago
JSON representation
Provides a ?? !! equivalent that tests for definedness instread of trueness.
- Host: GitHub
- URL: https://github.com/gfldex/perl6-operator-defined-alternation
- Owner: gfldex
- License: artistic-2.0
- Created: 2016-07-04T13:50:08.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-30T08:15:59.000Z (over 7 years ago)
- Last Synced: 2024-11-06T05:44:08.413Z (2 months ago)
- Language: Perl 6
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Operator::defined-alternation
[![Build Status](https://travis-ci.org/gfldex/perl6-operator-defined-alternation.svg?branch=master)](https://travis-ci.org/gfldex/perl6-operator-defined-alternation)Perl 6 provides control statements and operators to test for definedness instead of trueness, to provide ease of typing and a clear statement of intend from the programmer. Sadly there is currently no way to define your own ternary operators with Rakudo. However, we can emulate operators with 3 arguments with a chain of 2 infix operators, as long as we provide a type for the 2nd infix to handle dispatch properly.
## Usage:
```
use v6;
use Operator::defined-alternation;my $falsish = 2 but False;
say $falsish ?// 'defined' !! 'undefined';
# OUTPUT: defined
# What is equivalent to:
say $falsish.defined ?? 'defined' !! 'undefined';
# OUTPUT: defined
# But opposed to:
say $falsish ?? 'true' !! 'false';
# OUTPUT: false
```## License
(c) Wenzel P. P. Peppmeyer, Released under Artistic License 2.0.