Ruby Flashcards
Output a string on its own line
puts
Comment out a line
#
Operator to find the remainder when two numbers are divided
%
Format sequence to convert argument to string
%s
Example: puts “Let’s talk about %s.” % name
Format sequence to convert argument as a decimal
%d
example: puts “He’s %d pounds heavy.” % my_weight
Output string on the same line
Escape sequence to create a new line
/n
write a paragraph of text
«s something going on here.
With the PARAGRAPH thing
PARAGRAPH
Print variable to the next line after “puts”
,
Example:
puts “Here are the days: “, days
Escape sequence to create a tab
\t
Escape sequence to make a backslash
\
Take user feedback
gets
Return a String, removing carriage return characters
.chomp()
Load a library
require
String interpolation
{}
Standard input
STDIN
Pass an open file as an argument
File.open(filename)
The name of your script
$0
Put argument inputs from command line into an array
ARGV
Add information to a file
.write(“String”)