[Gambas-user] Arrays of mixed numeric type always float[] not variant[]
Brian G
brian at westwoodsvcs.com
Wed Mar 9 01:04:24 CET 2022
Yes I can do that, I guess I was not thinking...
Thanks. Tuesday, 08 March 2022, 10:33AM -08:00 from T Lee Davidson t.lee.davidson at gmail.com :
>On 3/7/22 14:28, Brian G wrote:
> When I create an array
>
> dim a = [1, 2, 3, 4, 4.5]
> Gambas always creates a float[] not variant[], which makes it impossible to add sets like [1,3,4] to the array later. Is this
> the correct
> behavior for mixed arrays of numbers?
>
>Is there a reason you can't declare the array as Variant[]? I don't have any problem inserting an integer array into a variant
>array.
>
>This code:
>Public Sub Main()
>
> Dim a As Variant[] = [1, 2, 3, 4.5, 5]
>
> a.Insert([6, 7, 8])
> For Each b As Variant In a
> Print b & "\t" & TypeOf(b)
> Next
>
>End
>
>Yields:
>1 7
>2 7
>3 7
>4.5 7
>5 7
>6 4
>7 4
>8 4
>
>
>--
>Lee
>
>----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220309/d8393262/attachment.htm>
More information about the User
mailing list