[Gambas-user] Another possible change...
Rob
sourceforge-raindog2 at ...94...
Sun Dec 14 23:25:46 CET 2003
On Sunday 14 December 2003 16:45, Nelson Ferraz wrote:
> >>newString = myString.Split(/\s/).Reverse().Join(' ')
> > Hummm ... I don't really understand this line... Do i must
> > understand dots as Pipe ?
> Each dot is a method invocation, but we could say they act
> like pipes. (I don't know if this actually works in Gambas; I
> borrowed the idea from Ruby)
Nah, native gambas datatypes don't have methods (except the array
classes in the gb core component.) But here's an equivalent one
liner in gambas:
newString = join(' ', reverse(split(' ', myString)))
assuming one writes reverse() as (warning, pseudo code ahead):
function reverse(instring as String[]) as String[]
dim outstring as String[]
dim i as integer
for i = 1 to instring.count
outstring.add(instring[instring.count - i])
' remember, arrays go from 0 to array.count - 1
next
return outstring
end
Of course a reverse() that just reverses a string is just as
trivial to write, quite seldom used, and therefore I don't
understand what this whole thread is about ;)
And don't the gambas gb component's array types have push and pop
methods, speaking of lists
Rob
More information about the User
mailing list