daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## The Code
  2.  
  3.  
  4. Object.constants.each do |str|
  5.     obj = Object.const_get(str)
  6.     puts "Class #{obj.name}" if obj.is_a?(Class)
  7.     puts "Class Variables #{obj.class_variables}" if obj.class_variables.empty?
  8. end
  9.  
  10. ## The Error
  11.  
  12. johnny@johnny-laptop:~/www/why/offbeatenpath$ ruby class_variables.rb
  13. Class ThreadError
  14. Class Variables
  15. Class Numeric
  16. Class Variables
  17. class_variables.rb:8: undefined method `class_variables' for "ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]":String (NoMethodError)
  18.     from class_variables.rb:5:in `each'
  19.     from class_variables.rb:5
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top