-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added support for construct
for var in array { ... }
The code is natively translated into an equivalent Perl loop: `for my $var(@{array}) {...}` Example: for i in [1,2,3,4] { say i; # prints each element from the array }
- Loading branch information
trizen
committed
Nov 17, 2015
1 parent
6f5fefb
commit 436a730
Showing
8 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package Sidef::Types::Block::ForArray { | ||
|
||
sub new { | ||
my (undef, %opt) = @_; | ||
bless \%opt, __PACKAGE__; | ||
} | ||
} | ||
|
||
1; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/ruby | ||
|
||
var arr = [1,2,3,4]; | ||
|
||
for i in arr { | ||
next if i==2; | ||
if (i == 2) { | ||
die "next error!"; | ||
} | ||
} | ||
|
||
var i = 42; | ||
assert_eq(i, 42); | ||
|
||
for i in arr { | ||
break if i==2; | ||
if (i >= 2) { | ||
die "break error!"; | ||
} | ||
} | ||
|
||
assert_eq(i, 42); | ||
i = 99; | ||
|
||
for i in arr { | ||
say i; | ||
} | ||
|
||
assert_eq(i, 99); |