From: Jens Wille Date: 2008-07-14T18:06:32+09:00 Subject: Re: Methods with [] braces can't take block arguments? hi! vikrambkumar@gmail.com [2008-07-13 22:40]: > I can't use c[:k] { block here } > > #-------- > c = L2Cache.new > c[:k] # >> nil > c.[:k] { "foo"} # >> syntax error, unexpected '{', expecting > $end > #-------- > > Is there a way to make methods names with special characters take > block arguments? well, the problem is not that the method name has special characters, but that what you're using is just syntactic sugar for that particular method name. it works perfectly fine when you use the regular syntax: c.[](:k) { 'foo' } # pretty ugly, eh? ;-) c.get(:k) { 'foo' } alternatively, you could pass in a proc argument like this: c[:k, lambda { 'foo' }] but you'd have to change your code to take that into account. cheers jens -- Jens Wille, Dipl.-Bibl. (FH) prometheus - Das verteilte digitale Bildarchiv f�r Forschung & Lehre Kunsthistorisches Institut der Universit�t zu K�ln Albertus-Magnus-Platz, D-50923 K�ln Tel.: +49 (0)221 470-6668, E-Mail: jens.wille@uni-koeln.de http://www.prometheus-bildarchiv.de/