forked from vlang/v
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker, cgen: implement method map() for fixed arrays (vlang#22644)
- Loading branch information
Showing
4 changed files
with
111 additions
and
20 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
fn test_fixed_array_map() { | ||
a := [1, 2, 3]! | ||
|
||
b1 := a.map(it * 2) | ||
println(b1) | ||
assert b1 == [2, 4, 6]! | ||
|
||
b11 := a.map(|x| x * 2) | ||
println(b11) | ||
assert b11 == [2, 4, 6]! | ||
|
||
b2 := a.map('${it}') | ||
println(b2) | ||
assert b2 == ['1', '2', '3']! | ||
|
||
b22 := a.map(|x| '${x}') | ||
println(b22) | ||
assert b22 == ['1', '2', '3']! | ||
|
||
b3 := a.map(it + 2) | ||
println(b3) | ||
assert b3 == [3, 4, 5]! | ||
|
||
b33 := a.map(|x| x + 2) | ||
println(b33) | ||
assert b33 == [3, 4, 5]! | ||
} |
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