W1 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

SyntaxError

A

Incorrect grammar in the structuring of the ruby code

Ex: my_array =

Need to have a value assign to it

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

NameError

A

A variable or method name that has not been defined

Ex: my_name = yangel
P name
Name was not previously defined

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

NoMethodError

A

Refers to a undefined method. It is
Considers a SPECIAL instance of a NameError

Ex:
def say_hello(name)
P “hi” + name
end

hello(“world”)

Because “hello” is not defined method

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

ArgumentError

A

Results of typically passing too little or too many arguments

Ex:
def say_hello(f_name, l_name)
p “hi” + f_name + “ “+ l_name
end

say_hello(“yangel”)
We only gave 1 argument when needing 2

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

TypeError

A

Result from performing an operation with a incompatible data type

5 + “spaghetti”

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

all?

A

Returns true when all elements in result in true when passed into the block

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

any?

A

Returns true when any of the elements results true when passed into the block

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

none?

A

Returns true when no elements of result in true when passed into the block

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

one?

A

Return true when exactly one element result in true when passed into the block

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

.count

A

Return a number representing the count of elements that result in true when passed into the block

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

.sum

A

Return the total sum of all elements

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

.max and .min

A

Return the maximum or minimum element

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

.flatten

A

Return the 1 dimensional version of any Multidimensional array

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

Symbols

A

Symbol and string are not equivalent. Symbols are immutable.

sym = :hello

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

*

A

Splat operator accepts additional arguments

The additional argument will be in a array

Best practice to put * at the end of the parameter

** performs similar unpacking of a hash key value pairs ( will only work with hashes where keys are symbol: )

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

str.each_char

A

Iterate through each character in the string !

17
Q

Bubble sort algorithm

A
def bubble (arr)
Sorted = false

While !sorted
Sorted = true

 Sorted = false
18
Q

[1,2,3] & [3,4,5]

A

Combines all like elements with in the arrays

[3]

19
Q

-3.abs

A

Return 3

Turns a - into a +