'-'.join(number)
(Damn!! I think Python spoiled me... )
B4X:
Dim number = "123" As String
Dim output = number.CharAt(0) As String
For i = 1 To (number.Length - 1)
output = output & "-" & number.CharAt(i)
Next
Log (output)
'-'.join(number)
(Damn!! I think Python spoiled me... )
B4X:
Dim number = 123 As String
Dim output = number.CharAt(0) As String
For i = 1 To (number.Length - 1)
output = output & "-" & number.CharAt(i)
Next
Log (output)
Using stringbuilder (which is supposed to be faster for string appends):
B4X:
Dim number = "123" As String
Dim output as stringbuilder
output.append(number.CharAt(0))
For i = 1 To (number.Length - 1)
output.append("-" & number.CharAt(i))
Next
Log (output.tostring)