From bret at pettichord.com Mon Jul 10 14:07:32 2006 From: bret at pettichord.com (Bret Pettichord) Date: Mon, 10 Jul 2006 13:07:32 -0500 Subject: [Wtr-development] Watir: next unless object == nil In-Reply-To: <2461CB9D-64D7-4B32-80AC-052C7D452849@hashref.com> References: <2461CB9D-64D7-4B32-80AC-052C7D452849@hashref.com> Message-ID: On 7/10/06, Xavier Noria wrote: > > Hi there! Just a quick question: I am reading watir.rb and see this > idiom in several places: > > object = nil > loop somehow > next unless object == nil > # assign to object somewhere > end > object > > That always exhausts the loop, why don't you stop as soon as possible > as in > > break if object > > ? I was going to write a patch but since you are experienced > developers I bet there is a reason for that. That is true. That code was originally written that way because if you did a break you would get a LocalJumpError from the WIN32OLE library. This was back in the days of Ruby 1.6. Since then, the WIN32OLE code has been fixed. Someone else recently contributed the very change you considered. You can find it in Watir 1.5. http://wiki.openqa.org/display/WTR/Project+Home Bret -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wtr-development/attachments/20060710/2c9f30ac/attachment.html From bret at pettichord.com Mon Jul 10 14:07:32 2006 From: bret at pettichord.com (Bret Pettichord) Date: Mon, 10 Jul 2006 13:07:32 -0500 Subject: [Wtr-development] Watir: next unless object == nil In-Reply-To: <2461CB9D-64D7-4B32-80AC-052C7D452849@hashref.com> References: <2461CB9D-64D7-4B32-80AC-052C7D452849@hashref.com> Message-ID: On 7/10/06, Xavier Noria wrote: > > Hi there! Just a quick question: I am reading watir.rb and see this > idiom in several places: > > object = nil > loop somehow > next unless object == nil > # assign to object somewhere > end > object > > That always exhausts the loop, why don't you stop as soon as possible > as in > > break if object > > ? I was going to write a patch but since you are experienced > developers I bet there is a reason for that. That is true. That code was originally written that way because if you did a break you would get a LocalJumpError from the WIN32OLE library. This was back in the days of Ruby 1.6. Since then, the WIN32OLE code has been fixed. Someone else recently contributed the very change you considered. You can find it in Watir 1.5. http://wiki.openqa.org/display/WTR/Project+Home Bret -------------- next part -------------- An HTML attachment was scrubbed... URL: From bret at pettichord.com Mon Jul 10 14:07:32 2006 From: bret at pettichord.com (Bret Pettichord) Date: Mon, 10 Jul 2006 13:07:32 -0500 Subject: [Wtr-development] Watir: next unless object == nil In-Reply-To: <2461CB9D-64D7-4B32-80AC-052C7D452849@hashref.com> References: <2461CB9D-64D7-4B32-80AC-052C7D452849@hashref.com> Message-ID: On 7/10/06, Xavier Noria wrote: > > Hi there! Just a quick question: I am reading watir.rb and see this > idiom in several places: > > object = nil > loop somehow > next unless object == nil > # assign to object somewhere > end > object > > That always exhausts the loop, why don't you stop as soon as possible > as in > > break if object > > ? I was going to write a patch but since you are experienced > developers I bet there is a reason for that. That is true. That code was originally written that way because if you did a break you would get a LocalJumpError from the WIN32OLE library. This was back in the days of Ruby 1.6. Since then, the WIN32OLE code has been fixed. Someone else recently contributed the very change you considered. You can find it in Watir 1.5. http://wiki.openqa.org/display/WTR/Project+Home Bret -------------- next part -------------- An HTML attachment was scrubbed... URL: