An exampleHello World program in Ruby:
An example program in Ruby that asks for your name and then says it:
puts"What's your name?"name=gets.chompputs"Ah hello there,#{name}"A function in Ruby that joins the 2 strings (or arrays/integers) into one, removes all numbers from it, capitalizes the string and then repeats it 5 times:
defsomefunction(arg1,arg2)# creates a function with 2 arguments. the args can be called anythingarg=arg1+arg2# this joins them into 1 stringarg=arg.tr("1234567890","")# this replaces all the numbers with a nothing. erases them essentially.arg=arg.capitalize# read that out loud5.timesdo# read that out loud tooputsarg# prints it on a new lineendendsomefunction("h1e2l6lo7,"," W5o6r8l9d!3")# does the functionOutput:
Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!