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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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]