January 2019
Intermediate to advanced
246 pages
5h 23m
English
It’s great to gather outside input for your program, but sometimes that input can create new challenges. You probably know the slogan “Garbage in, garbage out”: wrong input can corrupt all further processing. In our previous example, suppose the user enters a string such as "abc" when the program expects an integer number—a string that isn’t convertible to an integer. What happens then? Something awful: a runtime error or exception. As a professional programmer, you’ll want to avoid this at all costs.
| <= | Invalid Int8: abc (ArgumentError) |
| | 0x451477: *CallStack::unwind:Array(Pointer(Void)) at ?? |
| | 0x465a92: to_i8 at /opt/crystal/src/string.cr 358:5 |
| | ... |
You must always guard against dangerous input. The best ...
Read now
Unlock full access