You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hbase.apache.org by "Junegunn Choi (Jira)" <ji...@apache.org> on 2022/05/13 08:42:00 UTC
[jira] [Created] (HBASE-27030) Fix undefined local variable error in draining_servers.rb
Junegunn Choi created HBASE-27030:
-------------------------------------
Summary: Fix undefined local variable error in draining_servers.rb
Key: HBASE-27030
URL: https://issues.apache.org/jira/browse/HBASE-27030
Project: HBase
Issue Type: Bug
Affects Versions: 3.0.0-alpha-3
Reporter: Junegunn Choi
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.
{quote}
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
{quote}
{code:java}
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'
{code}
We can define the admin local variable in the current scope beforehand, and we can still access it after the block.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)