Skip to content
This repository
Browse code

Merge pull request #8641 from arunagw/warning_removed_unused_var

Remove 'assigned but unused variable' warning
  • Loading branch information...
commit 90397de416bb4d9d852a1baa65f954c81bf9911a 2 parents f75addd + f71aa35
Steve Klabnik authored December 28, 2012
3  activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -69,7 +69,8 @@ class Class
69 69
   # To opt out of both instance methods, pass <tt>instance_accessor: false</tt>.
70 70
   def class_attribute(*attrs)
71 71
     options = attrs.extract_options!
72  
-    instance_reader = options.fetch(:instance_accessor, true) && options.fetch(:instance_reader, true)
  72
+    # double assignment is used to avoid "assigned but unused variable" warning
  73
+    instance_reader = instance_reader = options.fetch(:instance_accessor, true) && options.fetch(:instance_reader, true)
73 74
     instance_writer = options.fetch(:instance_accessor, true) && options.fetch(:instance_writer, true)
74 75
 
75 76
     # We use class_eval here rather than define_method because class_attribute

0 notes on commit 90397de

Please sign in to comment.
Something went wrong with that request. Please try again.