Basics Flashcards

1
Q

What is Ruby?

A

Ruby is a high level programmming language

  • Ruby is Interperated (no need for a compiler)
  • Object oriented (allows users to manipulate data structures)
  • Easy to use
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What kind of data types are there in Ruby?

A
String = 'Hello'
Fixnum = Number
Integer = Number
Numeric = class of number like float, fixnum
Float = decimal number
NilClass = The class of the singleton object nil.
Hash =  A Hash is a dictionary-like collection of unique keys and their values. 
Symbol =Symbol objects represent names and some strings inside the Ruby interpreter. 
Array = A list of objects
Range = A Range represents an interval—a set of values with a beginning and an end.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a variable?

A

One of the most basic concepts in computer programming is the variable. You can think of a variable as a word or name that grasps a single value.

my_num = 25

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What arithmetic operator are there in ruby?

A
addition +
subtraction -
multiplication *
division /
modulo %
exponentiation **
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between puts and print?

A

print just prints whatever you give it to the screen
puts (“put string”) prints out what you give it with an empty line
So the difference is that puts has one more line
added.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a method in ruby?

A

They are built in abilities that objects have

methods can show you the length of a string or reverse the string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an interpreter?

A

An interpreter is a program that takes your code and runs it, it shows the result in your console

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you use a method?

A

Methods are used with a .

my_string = ‘i love pizza’ –> my_string.length –> 12

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do write a comment in ruby?

A

you use #

Everything behind the (on the same line) # will be commented out

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you do a multiline comment in Ruby?

A

You use =begin and =end

Everything in between will be commented out, you can use this to explain complicated concepts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a naming convention?

A

A naming convention is how the community writes code, local variables should be written in lowercase letters and words.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you declare or set a variable?

A

You use the =

my_number = 12

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you call multiple methods on a variable?

A

by chaining

name.method1.method2.method3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is chaining?

A

Chaining is that you call multiple methods on a variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly