News for hackers. Stuff that matters.
Re:Why Does “=” Mean Assignment? by lloeki on Tuesday April 10, 2018 @05:23PM (#16805590)
There is a Ruby idiom[0] that I find quite useful (esp. combined with a linter such as Rubocop), leveraging optional parens as a marker of intentional assignment:

  # bad
  if v = array.grep(/foo/)
    do_something(v)
    # some code
  end

  # good
  if (v = array.grep(/foo/))
    do_something(v)
    # some code
  end
Caught a number of nasty bugs that way.

[0]: https://github.com/bbatsov/ruby-style-guide#safe-assignment-...

Re:Why Does “=” Mean Assignment? by syrrim on Tuesday April 10, 2018 @07:29PM (#16806651)
You can catch this in c using -Wall.