Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
3.0.0-alpha-3
-
None
-
Reviewed
Description
HBASE-21812 replaced a for-loop with an each block. Each block introduces a new scope, so a local variable defined inside it cannot be accessed afterwards.
NameError: undefined local variable or method `admin' for main:Object
getServerNames at /opt/khp/hbase/bin/draining_servers.rb:81
addServers at /opt/khp/hbase/bin/draining_servers.rb:88
<main> at /opt/khp/hbase/bin/draining_servers.rb:146
for i in [1, 2, 3] a = i end puts a # 3 [4, 5, 6].each do |i| b = i end puts b # undefined local variable or method `b'
We can define the admin local variable in the current scope beforehand, and we can still access it after the block.
Attachments
Issue Links
- links to