public
Created

  • Download Gist
const_lookup.rb
Ruby
1 2
Object.const_defined? :Integer
#=> true
integer.rb
Ruby
1 2 3 4 5 6 7
class Integer
#...
end
 
def Integer(value)
#...
end
method_lookup.rb
Ruby
1 2
Object.private_method_defined? :Integer
#=> true
python_class_is_callable.py
Python
1 2 3 4 5 6 7
class MyClass:
def __init__(self, value):
self.value = value
 
my_class = MyClass(1) # We are calling the class to get
# an instance, instead of
# MyClass.new(1) in Ruby
ruby_class_looks_callable.rb
Ruby
1 2 3 4 5
Integer.class
#=> Class
 
Integer(1)
#=> 1

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.