Skip to content

Instantly share code, notes, and snippets.

@BanzaiMan
Forked from nelsnelson/wrapper_test.rb
Created August 22, 2011 03:40
Show Gist options
  • Save BanzaiMan/1161602 to your computer and use it in GitHub Desktop.
Save BanzaiMan/1161602 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
$ jruby jruby-6014.rb
Hi. I'd like to see what I look like during initialization. :)
self # => #<Klass:0xd2b918> (Klass)
Hi. I'd like to see what I look like during initialization. :)
self # => Sun Aug 21 23:40:01 EDT 2011 (JavaKlass)
#! /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
super
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