[Gambas-user] Array Shuffle method.
Gianluigi
bagonergi at gmail.com
Thu Mar 21 16:21:43 CET 2019
Il giorno gio 21 mar 2019 alle ore 16:01 T Lee Davidson <
t.lee.davidson at gmail.com> ha scritto:
> 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
>
>
Hi Lee,
For Shuffle to work, it is necessary to have the last master 2bb7d795
Regarding the code: Extract returns an array not a number.
Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190321/fdd4c64f/attachment.html>
More information about the User
mailing list