-
-
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
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
$ 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) |
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 | |
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