Skip to content

Instantly share code, notes, and snippets.

@AlexDaniel
Created January 6, 2019 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexDaniel/92f6f261cb6b4fbfced2c4a70b71c252 to your computer and use it in GitHub Desktop.
Save AlexDaniel/92f6f261cb6b4fbfced2c4a70b71c252 to your computer and use it in GitHub Desktop.
use Test;
class F {
has Str $.txt is rw;
method Numeric {
$!txt.defined ?? $!txt.starts-with(0..9) ?? +$!txt !! $!txt.unival.Int !! Real;
}
};
is(+F.new(txt=>"15"),15,"+15=15");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment