Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions




Ruby Programming
Previous Page Home Next Page

Boolean Expressions

Ruby has a simple definition of truth. Any value that is not nil or the constant false is true. You'll find that the library routines use this fact consistently. For example, IO#gets , which returns the next line from a file, returns nil at end of file, enabling you to write loops such as:

while line = gets
  # process line

However, there's a trap here for C, C++, and Perl programmers. The number zero is not interpreted as a false value. Neither is a zero-length string. This can be a tough habit to break.
Ruby Programming
Previous Page Home Next Page

  Published under the terms of the Open Publication License Design by Interspire