Created
May 28, 2020 06:15
-
-
Save khalidelboray/654d5b380be2e987f44927152af1802f to your computer and use it in GitHub Desktop.
Raku issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TextInput { | |
has $.value is rw is default(2); | |
method value() is rw { | |
return Proxy.new: | |
FETCH => sub ($) { return $!value }, | |
STORE => sub ($, $new) { | |
X::OutOfRange .new( | |
:range(0..50 ), | |
:got($new), | |
:what("Input Value")).throw if $new > 50; | |
$!value = $new * 5; | |
} | |
} | |
method inc-print { | |
$!value = $!value * 20; | |
say $!value | |
} | |
} | |
my $t = TextInput.new(); | |
$t.value = 5; | |
put $t.value; | |
# running this method will work so it is not readonly ? | |
#$t.inc-print |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
return
overridesis-rw