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:
The current Ruby approaches I know about: