[Gambas-user] How to extend the String[] class ??

Benoît Minisini benoit.minisini at gambas-basic.org
Thu Nov 23 14:02:21 CET 2023


Le 23/11/2023 à 12:32, BB a écrit :
> On 23/11/23 8:53 pm, Gianluigi wrote:
> 
>> Il 23/11/23 10:58, Martín ha scritto:
>>> Hi,
>>>
>>> I wan to extend the String[] class, I wan to add a method to remove 
>>> all the strings where its length = 0
>>> [...]
>>>
>>
>> Hi Martin
>>
>> Something like that?:
>> [...]
>>
> Yes that will work but it doesn't extend the String[] class.
> 
> I have not been successful trying the same. The native[] classes seem to 
> be a bit different.
> 
> b
> 

You can't create a class in the IDE with the "[]" characters in the 
name, so you can't extend the "String[]" class.

"[]" in a class name is a bit special. "String[]" is a normal class, 
but, for example, "Collection[]" or "String[][]" is an array of a normal 
class. It's a normal class, except that it is automatically created at 
runtime the first time you use it.

So allowing "[]" in a class name may lead to some problems at the 
moment. I must think about that.

But you can use normal class name for inheriting "String[]", it should work.

Regards,

-- 
Benoît Minisini.



More information about the User mailing list