Week 1 - Ruby Introduction Flashcards
Keywords
Words which have specific meaning or complete a special function in a programming language.
def
Used to define a method
end
Closes off the defintion of a method
What does calling a method mean?
Executes the method (things between def and end)
Prints a string of data, and doesn’t add a new line after executing.
puts
Prints a string of data, and adds a new line after executing.
gets
Requests a string of data to be used. (Enter your name here: )
String
A line of characters stored within quotations “…”
Integers
Whole numbers
Real/Float
Floating decimal point numbers
Booleans
True or false
Variables
A piece of data that we declare and is part of the computer’s memory which can be called on later.
Constant
A given value which will never change throughout the code
+ Signs
They are based on the context of data.
Can represent addition if there are integers.
Can also represent putting 2 strings together if strings.
Logic Error
An error made often due to typos
Syntax Error
An error made due to not following the rules of the programming language.
Eg: not including ‘ ‘ for print
Global Variable
A variable declared outside of a method, meaning that it can be called in any method.
Local Variable
A variable declared inside of a method (between def and end) and can only be used inside of that method.
Compiler
The program which runs the code
gets.chomp
Removes (chomps) any white space when requesting a string of info.
Pseudocode
Using the English language to explain what you want the code to do.
Statements
Just lines of code
Expression
Anything that can be evaluated to give a value.
Eg: 5+2 = 7, ‘Hello’ + ‘World’ = Hello World