[fxruby-users] Iterators
Philippe Lang
philippe.lang at attiksystem.ch
Fri Dec 15 16:42:57 EST 2006
Hi,
Attached to this message is an improved version of the FXRuby 1.6.3 iterators for FXTreeItem, FXTreeList, FXFoldingList, FXFoldingItem and FXTreeListBox.
The old version of the iterators was:
def each
current = first
while current != nil
yield current
current = current.next
end
self
end
If your decide to delete a node in the yield, your iterator fails when current.next is called, since current does not exist anymore...
The new version is:
def each
current = first
while current != nil
next_current = current.next
yield current
current = next_current
end
self
end
Cheers,
---------------
Philippe Lang
Attik System
-------------- next part --------------
A non-text attachment was scrubbed...
Name: iterators.rb
Type: application/octet-stream
Size: 8688 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/fxruby-users/attachments/20061215/be7691a7/attachment-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3125 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/fxruby-users/attachments/20061215/be7691a7/attachment-0001.bin
More information about the fxruby-users
mailing list