Ruby Rookie Question: How to Implement {} in Other Languages and Ruby?

  question, ruby

The {} in other languages is code block, ruby implementation, which seems a bit …

I want to implement code: (pseudo ruby code)

AString = "important things"
 count = 0
 {p "#{aString}, I said #{count+1} times "
 count += 1} while  count < 3

It is hoped that these two sentences will be executed together.

P"#{aString}, I said #{count+1} times "
 count += 1

I tried the Method, but it didn’t work either. Code:

def p_word(number)
 P "important things, I said #{number+1} times."
 number ++
 count = 0
 p_word(count) while  count < 3

Any suggestions?

do … then … end