Debugging Methods

Here are few methods that we can use for debugging:

1) Kernal#Caller


shows you where you have been.

It will give you “file:line in method”

2) Method

It is a class.

m = "Hello World".method(:upcase)
=> Method

3) source_location

It will give address and line number. It shows you where you are going.

It will give you address with line number of this above(:bark) method.

4) ancestors

=> [String, Comparable, Object, Kernal, BasicObject]

In class method you can simply call it like:


5) Module#method_defined?

=> true
=> false

6) Method#instance_method

Instead of

you can use:



here we don’t need to create instance.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s