fork download
  1. h = {"width"=>10, "length"=>20}
  2. s = "The dimension of the square is {{width}} and {{length}}"
  3. puts s.gsub(/\{\{(width|length)\}\}/) { h[Regexp.last_match[1]] }
Success #stdin #stdout 0.01s 6436KB
stdin
Standard input is empty
stdout
The dimension of the square is 10 and 20