From: Nic Daniau Date: 2007-05-01T19:14:43+09:00 Subject: Ruby syntax question: instance.method(args) { more_stuff } ------_=_NextPart_001_01C78BD9.88B09CF8 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, I'm having difficulty working out the following construct: img.write("myimage.jpg") { self.quality =3D 50 } In this example (source http://www.simplesystems.org/RMagick/doc/comtasks.html), img is a RMagick::Image. =20 The API says "You may also specify optional arguments by setting Image::Info attributes in an associated block." Is this a standard syntax in Ruby or is it specific to this write method? And how does it work, how can I make my own method accept blocks too? any advantage over passing a array of arguments? =20 Also, I'm trying to pass my own instance variable in order to replace the sample value of 50. So I've tried: =20 img.write("myimage.jpg") { self.quality =3D @my_object_quality } =20 Where @my_object_quality is defined as an instance variable on my class def. But the interpreters seams to look for a @my_object_quality instance variable *within* the RMagick class, which vaguely kind of make sense. So how can I pass this instance variable into this method? and why does it say "self.quality =3D 50" in the example and not "@quality = =3D 50"? =20 Thanks in adance for your help. I'm looking for a genuine explanation of what's happening at a Ruby syntax level, not just a code sample that would work with this RMagick example. =20 Nic =20 ------_=_NextPart_001_01C78BD9.88B09CF8--