Re: Manifest Array2?

"Eric Bezault ericb-D6Qt/9opevxWk0Htik3J/[email protected] [gobo-eiffel]" <[email protected]> Wed, 16 Oct 2019 23:09:23 +0200
Newsgroups gmane.comp.lang.eiffel.gobo.general
Message-ID <[email protected]>
On 16/10/2019 23:03, Eric Bezault wrote:
> Hi Germán,
> 
>> Is there a way to set an array2 in similar way of a manifest array? In
>> Liberty Eiffel I have something like:
>>
>> my_array2 := << 1, 2, 3;
>>                                4, 5, 6;
>>                                7, 8, 9 >>
>>
>> But don't seems possible in GOBO. Is there other way? Or I should add
>> elements one by one?
> 
> This syntax is not supported in the ECMA standard.
> I just had a look at class ARRAY2 from EiffelBase
> and it does not something like that either:
> 
>   my_array2 := << <<1, 2, 3 >>,
>                                 << 4, 5, 6>>,
>                                  7, 8, 9 >> >>
> 

You could write a routine which does that for you:

my_array2 := new_array2 (3, 3, <<1, 2, 3, 4, 5, 6, 7, 8, 9>>)

new_array2 (a_width, a_height: INTEGER; a_values: ARRAY [INTEGER]): 
ARRAY2 [INTEGER]
    require
        a_width_not_negative: a_width >= 0
        a_height_not_negative: a_height >= 0
        a_values_not_void: a_values /= Void
        consistent_size: a_width * a_height = a_values.count
    do
        ...

-- 
Eric Bezault
mailto:ericb-D6Qt/9opevxWk0Htik3J/[email protected]
http://www.gobosoft.com


------------------------------------
Posted by: Eric Bezault <ericb-D6Qt/9opevxWk0Htik3J/[email protected]>
------------------------------------

To Post a message, send it to:   [email protected]
To Unsubscribe, send a blank message to: [email protected]