Created
August 22, 2011 03:29
-
-
Save nelsnelson/1161598 to your computer and use it in GitHub Desktop.
This is a demo of an error I am seeing when attempting to access self inside the initialize method of a class
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
#! /usr/bin/env jruby | |
require 'java' | |
java_import java.util.Date | |
class Klass | |
def initialize | |
puts "Hi. I'd like to see what I look like during initialization. :)" | |
puts "self # => #{self} (#{self.class})" | |
end | |
end | |
class JavaKlass < Date | |
def initialize | |
puts "Hi. I'd like to see what I look like during initialization. :)" | |
puts "self # => #{self} (#{self.class})" | |
end | |
end | |
class Test | |
def initialize | |
@a = Klass.new | |
@b = JavaKlass.new | |
end | |
end | |
Test.new if __FILE__ == $0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment