Chapter 0-4 Flashcards

1
Q

In Ruby what is an object?

A

Literally everything integers characters, text arrays-everything.

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

what does the method .even? do??

A

Returns true and false in which the method determines whether the number or variable is even or odd.

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

What does the .next method do?

A

It increases the number or variable by plus one.

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

What do you do if you want to see the all the methods available to the data type?

A

After the data type put .methods, to see all the available methods.

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

What does the .index method do?

A

This method finds the position of the argument in the array and returns that data in the array.

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

What does the method .between? do??

A

It is a method to determine if the number lies between two numbers Ex. 2.between? 1,3 Returns true.

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

What does the .length method do?

A

It returns the number of characters in a string including spaces.

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

What is string interpolation?

A

It is a placeholder that replaces placeholders with values they represent.

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

What does the method .include? do??

A

It sorts for a certain number of characters within a string

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

What does the .start_with? do??

A

It check to see if a string starts with a certain set of characters.

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

What does the .end_with? method do??

A

It checks to see if a string end with a certain set of characters.

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

What does the .index() method do??

A

It find a certain set of characters and returns the index of the character or characters.

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

What does the methods .uppercase and .downcase do?

A

.uppercase makes the whole string captial letters and downcase puts all the lets to the standard form.

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

What does the .swapcase method do?

A

Swap every character in the string to lower case to upper case and vice versa.

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

What does the method .split do?

A

Returns an array for a string generally separated by a space(‘’)

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

What does the .sub() method do??

A

Takes a substring from a string and replaces it with another substring. But only for the first string it encounters. .sub(old substring, new substring)

17
Q

What does the .gsub() method do?

A

Like .sub() method it replaces string with another string but all occurrences for when it is called.

18
Q

What does the .match method do?

A

converts a pattern of Regular expressions and invokes its match method on the target String method.

19
Q

What does the || and && do in Ruby programming?

A

For if else statements represents or along with and.

20
Q

How do you negate a expression?

A

Use the ! point.

21
Q

What is the ? and : used for?

A

They mean then and else respectively. ex. number>0? – : —

22
Q

What does the infinite loop look like?

A

loop do some code end

23
Q

What is the break command used for?

A

Its ends the loop including infinite loop

24
Q

How do you run a block of code N times?

A

(some number).times do end

25
Q

How does one create a new array?

A

Array.new

26
Q

How do you find data in an array?

A

[data][subdata] subdata= data that you are trying to find

27
Q

What is a reverse index lookup?

A

Array indexes can also start from the end of the array, rather than the beginning! In Ruby, this is achieved by using negative numbers.

28
Q

How does a coder increase an array?

A

after the array use

29
Q

What does .push() do?

A

Increases the array with data.

30
Q

What does the map method do?

A

sdf