News for hackers. Stuff that matters.
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by bradly on Saturday January 08, 2011 @02:31AM (#2082566)
> Any modern should not allow 'if(flag=0)'.

This is how you set default values for optional argument in Ruby and is very common.

Re:Which one will execute faster, if(flag==0) or if(0==flag)? by chc on Saturday January 08, 2011 @04:39AM (#2082738)
I have never seen "if foo = 0" used to set a value for an optional argument in Ruby. It would either be "def bar(foo=0)" or "foo ||= 0". Can you give any example of what you're talking about?
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by bradly on Saturday January 08, 2011 @04:16PM (#2083980)
My mistake. I didn't read parent carefully enough. Although it is common to see something like:

  if(@post = Post.find(params[:id]))
    render @post
  else
    render 'Post not found'
  end