Skip to content

Commit 10c8fb6

Browse files
committed
Merge pull request #14 from dotdoom/master
Update debugging answers
2 parents d84162b + 5463c4b commit 10c8fb6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ Q: What is the difference between `#to_s` and `#inspect`?
633633
A: `#inspect` is the same as `#to_s`, except some classes redefine `#inspect` to provide output that is more helpful for debugging.
634634

635635
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`.
637637

638638
Q: Which Ruby interpreter option enables debugging?
639639
A: `-d` / `--debug`
@@ -642,19 +642,19 @@ Q: What is the global variable for the last exception raised?
642642
A: `$ERROR_INFO` equivalent to `$!`
643643

644644
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)
646646

647647
Q: What does `Kernel#__method__` return?
648648
A: The name of the currently executing method as a symbol.
649649

650650
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).
652652

653653
The Ruby Environment and the Interpreter
654654
-------------------------------------------------------------------------------
655655

656656
Q: What is the difference between `#puts` and `#print`?
657-
A: `#puts` appends a newline character to the output.
657+
A: `#puts` appends a newline character to the output. `#print` prints a value of special variable `$_` when called without arguments.
658658

659659
Q: Which Ruby interpreter option allows running of one-line scripts?
660660
A: `-e`

0 commit comments

Comments
 (0)