From: Henry Maddocks Date: 2012-10-12T05:46:48+09:00 Subject: Re: Explanation of # and @#. On 12/10/2012, at 9:33 AM, Muhammad Salman wrote: > I am relatively new to Ruby. In the below code which redefines the > attr_accessor method i cannot understand the #{attr} and @#{attr}. I > know # as comment and @ as required for a instance variable in Ruby. %Q{ def #{attr} @#{attr} end def #{attr}=(value) @#{attr} = value end } The # symbol when used with {} is for string interpolation, e.g.. f = "world" puts "hello #{f}" %Q is another way of defining a string with interpolation, e.g. f = %Q{world} puts "hello #{f}" Henry