Presentation is loading. Please wait.

Presentation is loading. Please wait.

Learning Ruby - 5 Files. while line = gets puts line end while line = gets puts line.downcase end while line = gets puts line.downcase if line =~ /UP/

Similar presentations


Presentation on theme: "Learning Ruby - 5 Files. while line = gets puts line end while line = gets puts line.downcase end while line = gets puts line.downcase if line =~ /UP/"— Presentation transcript:

1 Learning Ruby - 5 Files

2 while line = gets puts line end while line = gets puts line.downcase end while line = gets puts line.downcase if line =~ /UP/ end The "readlines" Program x 3

3 File.open( "/etc/passwd" ) do |my_file| my_file.each_byte do |byte| putc byte; print "." end # of do. File.open( "/etc/passwd" ) do |my_file| my_file.each_line { |line| puts line } end # of do. IO.foreach( "/etc/passwd" ) { |line| puts line } File Reading Iterators

4 print STDOUT << "Hello" << " " << "World!" << "\n" Ruby's a bit like C++ - Yuk!

5 More... Ruby So Far Files are easy to work with in Ruby Take advantage of the in-built iterators and methods when working with files


Download ppt "Learning Ruby - 5 Files. while line = gets puts line end while line = gets puts line.downcase end while line = gets puts line.downcase if line =~ /UP/"

Similar presentations


Ads by Google