[Gambas-user] Using strings like objects

Fabien Bodard gambas.fr at gmail.com
Sun Sep 23 11:07:48 CEST 2018


Le dim. 23 sept. 2018 09:28, Benoît Minisini <g4mba5 at gmail.com> a écrit :

> Hi,
>
> Since last commit, I allowed strings to be used like objects.
>
> This is not syntactic sugar, as it is entirely implemented in the
> interpreter.
>
> So now, if S is a string, you can do the following:
>
> S[N] to get the N-th character of the string. Beware! Contrary to string
> subroutines, the first character position is zero. It's like using the
> string as a character array.
>
> S[N, L] is an equivalent of Mid$(S, N + 1, L).
>
> S.Len returns the length of the string.
>
> S[] only deals with byte position, it can't handle UTF-8.
>
> That new syntax is slower than calling directly Mid$() and Len(), but I
> don't think we will notice the difference.
>
> Maybe I will add a S.Max property to returns the length minus one, but I
> don't think I will implement all the string routines as object methods.
>
> Tell me what you think about that.
>
I think it's coool but I want all the string functions 😊

> --
> Benoît Minisini
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20180923/a1f9776c/attachment.html>


More information about the User mailing list