Skip to content

Instantly share code, notes, and snippets.

@nelsnelson
Created August 22, 2011 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nelsnelson/1161598 to your computer and use it in GitHub Desktop.
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
#! /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