From: Henry Maddocks Date: 2013-02-11T08:15:24+09:00 Subject: Re: Ruby Equivalent to VB's "With"? On 11/02/2013, at 9:25 AM, Joel Pearson wrote: > I've looked around but I couldn't find anything helpful on this, > although I'm sure it's been covered before: > Does Ruby have an equivalent to the "With / End With" syntax helper in > VB? It would be quite helpful when I need to execute a series of methods > on an object, but for various reasons (e.g. testing individual returns > or methods which may return nil) I don't want to chain them together. > > To illustrate, here's the VB syntax I'm referring to: > > With my_object > .do1 > .do2 > .do3 > End With tap? my_object.tap do |mo| mo.do1 mo.do2 mo.do3 end Henry