[Rails] Re: An idea for new syntactic sugar in Ruby

2011-02-14 Thread Kai Middleton
variable stays in scope, which is not so nice. On Feb 14, 5:18 pm, Kai Middleton kai.middle...@gmail.com wrote: I was looking at this bit of code within Rails: # File actionpack/lib/action_controller/metal/flash.rb, line 12 def redirect_to(options = {}, response_status_and_flash = {}) #:doc

[Rails] Re: An idea for new syntactic sugar in Ruby

2011-02-14 Thread Kai Middleton
I also found this on stackoverflow: http://stackoverflow.com/questions/3835170/ruby-assignment-and-comparison-in-one-line On Feb 14, 5:18 pm, Kai Middleton kai.middle...@gmail.com wrote: I was looking at this bit of code within Rails: # File actionpack/lib/action_controller/metal/flash.rb

[Rails] Re: An idea for new syntactic sugar in Ruby

2011-02-14 Thread Kai Middleton
Yeah, great point. How to know how deep to go. I was looking at some of the Ruby global vars: http://www.rubyist.net/~slagell/ruby/globalvars.html This one is similar: $n the nth subexpression in the last match (same as $~[n]) But it seems somehow not so clean. We have this nifty

[Rails] Re: Regex for string first chars - Model validation

2011-02-11 Thread Kai Middleton
Philip's idea seems pretty good: ^\w+ That says: look for any string that starts with one or more word characters (letters, numbers, underscores). Try it out in rubular: http://rubular.com/ It let's you quickly experiment with lots of regular expressions and has a quick-ref right there on the