1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

array: [].map(fn...) return type can be different than original type (#7300)

This commit is contained in:
LilEnvy
2020-12-12 18:29:48 -08:00
committed by GitHub
parent e6f651978e
commit 0aacc9a80a
8 changed files with 48 additions and 9 deletions

View File

@ -676,6 +676,23 @@ fn test_anon_fn_arg_map() {
assert a == [2,3,4]
}
fn test_anon_fn_arg_different_type_map() {
i_to_str := fn (i int) string {
return i.str()
}
a := [1, 2, 3].map(i_to_str)
assert a == ['1', '2', '3']
}
fn test_anon_fn_inline_different_type_map() {
a := [1, 2, 3].map(fn (i int) string {
return i.str()
})
assert a == ['1', '2', '3']
}
fn test_array_str() {
numbers := [1, 2, 3]
assert numbers == [1,2,3]