Re:Ruby One-Liners
by jhbadger on Friday September 13, 2019 @11:33PM
(#20968767)
It's basically there to make Ruby an equivalent to AWK. It only makes sense if you are looping over the lines with -n. The BEGIN block runs at the start of the run, and the END block at the end. They are useful for things like initializing a sum variable to zero at the start and printing it out at the end.
[ Parent
| on HN ]
There are no comments on this comment yet.