Issue #18125 has been updated by matz (Yukihiro Matsumoto).

Status changed from Open to Closed

Local variables are defined when they appear in assignments, thus

```ruby
  deploy_to = "#{deploy_to} new place"
# ^ assignment   ^local variable
```

To avoid ambiguity, use parenthesis.

```ruby
  deploy_to = "#{deploy_to()} new place"
```

Matz.


----------------------------------------
Misc #18125: A strange behavior when same name variable/method coexist issue.
https://bugs.ruby-lang.org/issues/18125#change-93451

* Author: zw963 (Wei Zheng)
* Status: Closed
* Priority: Normal
----------------------------------------
Following is a example.

## Reproduce

```rb
def deploy_to
  "deploy_to"
end

deploy_to = "#{deploy_to} new place"

p defined? deploy_to # => local_varible
p deploy_to  # => " new place"
```

## What we expected.

```rb
def deploy_to
  "deploy_to"
end

deploy_to = "#{deploy_to} new place"

p defined? deploy_to # => local_varible
p deploy_to  # => "deploy_to new place"
```


This strange behavior i found it after several years ruby programming.

Perhaps this is always the expected behavior?

i report here for check anyway





-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>