#!/usr/bin/rubyputs"Hello, Ruby, what is your name?"$name=stdin.getsputs"Hi, I am"+$namedefWelcome (Name,a = 9,b = 9,*c) puts"Hi #{name}"c.each{|x|Print "#{x}"}#print "a =" + $aA = 10; b = 11#print "Hi, B" + $bres = A *Bend#Welcome ("RUBY")Puts welcome"Ruby", 3,6,7,8x= 100000000000000000000puts"#{x}"+ x.class. To_sputs"Hello". UpCase () s="shit"; f ="Fuck"s,f=F,sarr= [1, 2, S, f]puts arr[2]puts arr[-1]puts Arr.inspect#Hash TableCars = { 'Altima'='Nissan', 'Camry'='Toyota', 'RX7'='Mazda'}cars['v'] ='Volkswagon'puts cars['RX7']p cars['v']#puts *.inspect abbreviationP Cars#Each iterationtoppings = hash["Pancakes","Syrup","Pizza","Pepper","Cereal","Sugar"] toppings.each{|name, price| Puts"#{name} points to #{price}"}mytoppings= Toppings.select{|name, price| price >"Pepper"}p Mytoppings.inspect#using of the. [] and ... [)('a'..'g'). each{|letter|PrintLetter }puts ('a'...'g'). each{|letter|PrintLetter }puts
Save as *.rb file and execute Ruby *.rb at the terminal.
Ruby Learning Notes