2013-06-01から1ヶ月間の記事一覧

Control Structures

x=ARGV[0].to_f #Convert first argument to a number y=ARGV[1].to_f #convert second argument to a number sum=x+y #Add the arguments puts sum #Print the sum#if x is less than 10, increment it #same simple conditional x=1 while x if x x+=1 put…

x,y=1 #x=[]; y=1

x,y,*z=1,*[2,3,4] #x=1;y=2;z=[3,4];

x,y=1,2 #x=[1]; y=2

x,y=1,2,3 #x=[1,2]; y=3

x,y=1 #x=[]; y=1

x,y=1,2 #x=[1]; y=2

x,y=1,2,3 #x=[1,2]; y=3

x,y=1 #x=[]; y=1

x,y=1,2 #x=[1]; y=2

x,y=1,2,3 #x=[1,2]; y=3

x,y=1 #x=[]; y=1

x,y,*z=1,*[2,3,4] #x=1;y=2;z=[3,4];#operator puts (0b1011 puts (0b10110 >> 2).to_s(2) #101 puts 11 puts 22>>2 #5message="hello" messages=[] message messages

x,y=1,2 #x=[1]; y=2

x,y=1,2,3 #x=[1,2]; y=3

x,y=1 #x=[]; y=1

x,y,*z=1,*[2,3,4] #x=1;y=2;z=[3,4];#operator puts (0b1011 puts (0b10110 >> 2).to_s(2) #101 puts 11 puts 22>>2 #5message="hello" messages=[] message messages

x,y=1,2 #x=[1]; y=2

x,y=1,2,3 #x=[1,2]; y=3

x,y=1 #x=[]; y=1

x,y,*z=1,*[2,3,4] #x=1;y=2;z=[3,4];#operator puts (0b1011 puts (0b10110 >> 2).to_s(2) #101 puts 11 puts 22>>2 #5

x,y=1,2 #x=[1]; y=2

x,y=1,2,3 #x=[1,2]; y=3

x,y=1 #x=[]; y=1

x,y,*z=1,*[2,3,4] #x=1;y=2;z=[3,4];puts (0b1011 puts (0b10110 >> 2).to_s(2) #101 puts 11 puts 22>>2 #5

x,y=1,2 #x=[1]; y=2

x,y=1,2,3 #x=[1,2]; y=3

x,y=1 #x=[]; y=1

x,y,*z=1,*[2,3,4] #x=1;y=2;z=[3,4];#operator puts (0b1011 puts (0b10110 >> 2).to_s(2) #101 puts 11 puts 22>>2 #5message="hello" messages=[] message messages

x,y=1,2 #x=[1]; y=2

x,y=1,2,3 #x=[1,2]; y=3

Expressions and Operator

#method invocations puts "hello world" #"puts" invoked on self , with one string arg puts Math.sqrt(2) #"sqrt" invoked on object Math with one arg message="hello world" puts message.length #"length" invoked on object message;no args a=[0,1…