From: Gavin Sinclair Date: 2002-09-27T22:55:13+09:00 Subject: Re: Ruby - common pitfalls? ----- Original Message ----- From: "Rudolf Polzer" > > > > > > Maybe it's less tempting to write a Pascal-style equality test if the if > > > syntax does not look exactly like Pascal. > > > > Instead of finding "workarounds" to make Ruby look like Pascal or Bash, why not > > just learn Ruby properly? Use -w always. > > -w tells you the error *after* you have done it. It would be better it it > would not happen at all. That's pretty common where languages, interpreters and warning are concerned :) > And sometimes such code is written on purpose: > > if retval = foo > # use retval > end > > creates a warning. > > if retval = foo () > # ... > end > > creates another one ("foo (...) interpreted as method call"). What else > could it be? To me it just looks better when there's a space between the > method name and the opening brace. I know it is interpreted as method > call then and not as first argument. Is there a way to disable this > single warning? I doubt it. > > > ---------------------------------------------------------------------------- > > > > > - a %= b versus %=...=. A syntax highlighter gets into big trouble [...] > > > > So use another character. > > *I* use another character. But when I use %= to get the modulus (a %= > 3), vim's highlighting fails and I have to write a comment (#=) to make > vim highlight the rest of the code correctly. > > I don't want to always write > > a = a % 3 > > just to make it easier to vim. > Fair enough. Sorry, I misunderstood the problem. Have you informed the syntax maintainer for ruby/vim? Aside: in all my years of programming, I've used % rarely and %= extremely rarely. When I did use %= (in C++ I think), I actually expanded it because %= wasn't a common enough idiom in my experience, so a = a % 3 made more sense. Gavin