Inner function in Ruby

Viewed 217

In JS, inner functions could be quite handy to simplify the code, something like:

function complexStuff() {
  function step1() { ... }
  function step2() { ... } 

  step1()
  step2()
}

Is it possible to use something similar in Ruby, or are there different approaches?

I don't like private methods because private methods are available to the whole class, and in this case, I want to limit the scope of the inner function even more--to just one method.

1 Answers
Related