This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.
| Converting Between Characters and Values | ||
|---|---|---|
| Code | Expected | Actual |
?a |
97 | 97 |
?! |
33 | 33 |
?\n |
10 | 10 |
'a'[0] |
97 | 97 |
'bad sound'[1] |
97 | 97 |
97.chr |
"a" | "a" |
33.chr |
"!" | "!" |
10.chr |
"\n" | "\n" |
0.chr |
"\000" | "\000" |
256.chr |
RangeError: 256 out of char range ... |
RangeError: 256 out of char range from (irb):10:in `chr' from (irb):10 |