From: "mame (Yusuke Endoh)" Date: 2012-11-25T18:17:03+09:00 Subject: [ruby-core:50072] [ruby-trunk - Feature #7432][Assigned] Explicit way to define local variable in scope Issue #7432 has been updated by mame (Yusuke Endoh). Status changed from Open to Assigned Assignee set to matz (Yukihiro Matsumoto) Priority changed from Normal to Low Target version set to Next Major Assigning to matz, but don't hold your breath; matz has rejected such a explicit variable declaration syntax many times. -- Yusuke Endoh ---------------------------------------- Feature #7432: Explicit way to define local variable in scope https://bugs.ruby-lang.org/issues/7432#change-33851 Author: prijutme4ty (Ilya Vorontsov) Status: Assigned Priority: Low Assignee: matz (Yukihiro Matsumoto) Category: Target version: Next Major Imagine code such as this def test_smth result = nil assert_nothing_raised { result = some_slow_calculation } assert_equal expected_answer, result end Line `result = nil` means nothing more than our intention to simply bind variable `result` in scope of assertion block with outer local variable. In large methods it can be much heavier to find out this obscured intention. It may be better to introduce a method (if it can be implemented) or a keyword which simply creates a local variable (probably with nil value just to mark its existence) define_variable 'x' or (define_variable x if it's a keyword) -- http://bugs.ruby-lang.org/