Skip to content

Commit

Permalink
- Added the Ref = method which assigns a value to the referenced va…
Browse files Browse the repository at this point in the history
…riable.

Example:
	var x = 42;
	\x = 21;		# is equivalent with: x = 21
  • Loading branch information
trizen committed Sep 10, 2015
1 parent ce4fac6 commit d475f33
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/Sidef/Variable/Ref.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ package Sidef::Variable::Ref {
$self;
};

*{__PACKAGE__ . '::' . '='} = sub {
my ($self, $value) = @_;
state $method = '=';
$self->{var}->$method($value);
};

foreach my $method (qw(-- ++)) {
*{__PACKAGE__ . '::' . $method} = sub {
my ($self, $var) = @_;
Expand Down
2 changes: 1 addition & 1 deletion scripts/Rosettacode/Last_Sunday_of_each_month.sf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ range(1, 12).each { |i|
);

while (date.dow != 7) {
[date.subtract(days => 1)] » \date;
\date = date.subtract(days => 1);
};

say date.ymd;
Expand Down

0 comments on commit d475f33

Please sign in to comment.