V: Array join function

Created on 24 Jun 2020  路  3Comments  路  Source: vlang/v

It would be great to have an array.join(seperator) function, like the one in JS or in C#.

In my mind it would work somewhat like this:

nums := [1, 2, 3]
println(nums.join("-")) // 1-2-3
Feature Request

Most helpful comment

Yeah I think it should stay nums.map(it.str()).join('-')

It's easier and more explicit.

It's not very clear that []int.join() returns a string

All 3 comments

@Cyklan currently join only works on array of strings, so the workaround you have to do right now is to convert the values into strings and invoke .join('-')

nums := [1, 2, 3]
println(nums.map(it.str()).join('-'))
// 1-2-3

Yeah I think it should stay nums.map(it.str()).join('-')

It's easier and more explicit.

It's not very clear that []int.join() returns a string

Closed. []int.join won't be implemented.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

radare picture radare  路  3Comments

radare picture radare  路  3Comments

cjmxp picture cjmxp  路  3Comments

markgraydev picture markgraydev  路  3Comments

medvednikov picture medvednikov  路  3Comments