[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Newbie ahead!: Ruby-Demo

Peña, Botp

1/21/2006 5:23:00 AM

Meino Christian Cramer [mailto:Meino.Cramer@gmx.de] :

# can someone point me to a ruby demo-script?
#
# I want to show a friend the beauty of ruby and am myself fear if
# would try my best would acchieve the opposite of what I want.
#
# It dont need to do anything sophisticated it only should show the
# Pros of programming in ruby...


Show "Hello, world." in 3 ways.

Way 1. print hello world on screen.
code: puts "Hello, world."
audience comment: hmmmm.... ok..

Way 2. print helloworld 100 times
codeA. puts "Hello, world.\n" * 100
or
codeB. 100.times{ puts "Hello, world."}
audience comment: coool..l :-)

Way 3. print helloworld to pdf.
code: require "pdf/writer"
pdf = PDF::Writer.new
pdf.select_font "Times-Roman"
100.times {pdf.text "Hello, world."}
pdf.save_as("hello.pdf")
audience comment: ..cannot comment... audience rotfl...