temp = 98.3 begin print 'Your temperature is ' + temp.to_s + ' Fahrenheit. ' puts 'I think you're okay.' temp += 0.1 end while temp < 98.6
In the above example, is everything between begin and end a block?
I’m still confused what a block is.
If you can’t call it a block, what would you call that chunk of code between begin and end? Is it ok to call it a chunk?
Block has a special meaning in Ruby. According to Matz, Ruby’s creator, you can look at a block as a nameless function – typically something that can be
yielded into, and which may also take parameters.You may see the following kind of disamiguation when describing Ruby syntax:
begin…end(what is called block in other languages) may sometimes be referred to simply as what it is, i.e. an expression (which may in turn contain other expressions – an expression is simply something that has a return value) in Ruby. Some references will still call it abegin/end block, or acode block, adding somewhat to the confusiondo…endor{...}will always be referred to as a block in RubyFor examples, peruse the the Ruby syntax man page, e.g.
For further reading, see: