You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -633,7 +633,7 @@ Q: What is the difference between `#to_s` and `#inspect`?
633
633
A: `#inspect` is the same as `#to_s`, except some classes redefine `#inspect` to provide output that is more helpful for debugging.
634
634
635
635
Q: What is the difference between `#puts` and `#p`?
636
-
A: `#p` converts objects to strings with an `#inspect` method instead of with a `#to_s`method.
636
+
A: `#p` converts objects to strings with an `#inspect` method and returns argument(s) as a result (useful to inject directly into the method argument list). `#puts` uses `#to_s`and returns `nil`.
637
637
638
638
Q: Which Ruby interpreter option enables debugging?
639
639
A: `-d` / `--debug`
@@ -642,19 +642,19 @@ Q: What is the global variable for the last exception raised?
642
642
A: `$ERROR_INFO` equivalent to `$!`
643
643
644
644
Q: How can you obtain the current state of the call stack?
645
-
A: Using `Exception#backtrace` or `Kernel#caller`
645
+
A: Using `Exception#backtrace`(state at exception raise), `Thread.current.backtrace` (current state) or `Kernel#caller` (does not include current line)
646
646
647
647
Q: What does `Kernel#__method__` return?
648
648
A: The name of the currently executing method as a symbol.
649
649
650
650
Q: What is the synonym of `Kernel#__method__`?
651
-
A: `Kernel#__callee__`
651
+
A: `Kernel#__callee__` (the difference since Ruby 2.0 is that `__callee__` returns the name of an aliased method, if any).
0 commit comments