- 
      
- 
        Save ctide/3753494 to your computer and use it in GitHub Desktop. 
    Weird Ruby Behavior
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class MyClass | |
| def value | |
| "VALUE!" | |
| end | |
| def do_something | |
| puts defined?(value) # Outputs "method" | |
| puts value # Outputs "VALUE!" | |
| if false | |
| value = 'abcdef' # Should not execute | |
| end | |
| puts defined?(value) # Outputs "local-variable" | |
| puts value # Outputs nothing | |
| end | |
| end | |
| MyClass.new.do_something | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment