[Gambas-user] String[].Extract not behaving as expected
T Lee Davidson
t.lee.davidson at ...626...
Thu Dec 4 01:41:15 CET 2014
http://gambaswiki.org/wiki/comp/gb/string[]/extract says:
[edited-quote]
Function Extract (Start As Integer [, Length As Integer ]) As String[]
If Length is negative, then Length elements counting backwards from the
specified Start are removed.
[/edited-quote]
But this does not appear to be the manner in which it behaves. (I am
also unsure what "counting backwards" means. Would that be toward the
beginning or the end of the array?)
Public Sub Main()
Dim myStrings As String[] = ["s1", "s2", "s3", "s4", "s5", "s6", "s7"]
Dim sString As String
myStrings = myStrings.Extract(2, -1)
Print "Number of extracted elements: " & myStrings.Count
For Each sString In myStrings
Print sString
Next
End
produces:
Number of extracted elements: 5
s3
s4
s5
s6
s7
Obviously, "myStrings.Extract(2, -1)" extracted all elements from the
specified Start to the end of the array, not just one element from the
specified Start.
"myStrings.Extract(2, -2)" gives an "Out of bounds" error.
So, I guess my question should be, what is the intended behavior?
--
Lee
__________
"Artificial Intelligence is no match for natural stupidity."
More information about the User
mailing list