[Gambas-user] Array.Sort
Lewis Balentine
lewis at ...3412...
Thu Jan 8 06:59:04 CET 2015
Do I have it correct now ??
The program runs and operates as expected.
My concern is more to the proper nomenclature than function.
Regards,
Lewis Balentine
'--- --- (project archive attached to message) --- ---
Private Function TestFunction() As String[]
Return ["abcdefghij", "1234567890", "ABCDEFGHIJ"]
End
Private Sub DoPrint(XXX As String[])
Dim S As String
For Each S In XXX
Print S
Next
Print "------"
End
Public Sub Main()
Dim XXX As New String[]
' NOTE:
' The empty set of parentheses is REQUIRED when
' sort is used as a function to return an array.
' array=array.sort() will work
' array=array.sort will not work
DoPrint(TestFunction())
DoPrint(TestFunction().sort())
'
XXX = TestFunction()
DoPrint(XXX)
DoPrint(XXX.Sort())
'
XXX = TestFunction().sort()
DoPrint(XXX)
'
' NOTE:
' The empty set of parentheses is NOT required when
' sort is used as a procedure call to simply sort
' array without returning anything.
' array.sort() will work
' array.sort will work
XXX = TestFunction()
XXX.Sort
DoPrint(XXX)
'
' array.reverse and array.pop work similarly.
DoPrint(XXX.Reverse())
XXX.Reverse
DoPrint(XXX)
XXX.Pop
Print XXX.Pop()
' parentheses are not used for an array's properties
Print "======"
XXX = TestFunction()
Print "'array.dim' returns the number of dimensions in an array: "
& XXX.dim
Print "'array.length' returns the number of items in an array: "
& XXX.length
Print "'array.count' returns the number of items in an array: "
& XXX.count
Print "'array.max' returns the number of items in an array: "
& XXX.max
Quit
End
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ArrayExample-0.0.1.tar.gz
Type: application/gzip
Size: 4406 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20150107/f8ae0cb7/attachment.gz>
More information about the User
mailing list