[Gambas-user] Array Shuffle method.
T Lee Davidson
t.lee.davidson at gmail.com
Thu Mar 21 16:00:54 CET 2019
On 3/21/19 8:22 AM, Gianluigi wrote:
> Hi,
> can this be a correct use of the array Shuffle method?
>
> [code]
> Public Sub Main()
>
> Dim aBingo As New Byte[]
> Dim iPull As Byte
>
> For i As Byte = 0 To 89
> aBingo.Push(i + 1)
> Next
> aBingo.Shuffle()
> iPull = aBingo[aBingo.Max]
> Print "Extract "; iPull; "\n"
> aBingo.Resize(aBingo.Max - 1)
> '-------------------------------
> Print "Checking:"
> aBingo.Sort()
> For Each i In aBingo
> Print i
> Next
>
> End
> [/code]
>
> Regards
> Gianluigi
According to the Wiki, Byte[] has a Shuffle method. But, when I try to run your code, I get:
"Unknown symbol 'Shuffle' in class 'Byte[]'" Same thing on the Gambas Playground: http://gambas.one/playground/ultra.php
Other than that, I think your use of the shuffle method would be a correct use. Although, you should be able to simply use:
iPull = aBingo.Extract(aBingo.Max)
instead of:
iPull = aBingo[aBingo.Max]
aBingo.Resize(aBingo.Max - 1)
___
Lee
More information about the User
mailing list