Methods, Blocks & Sorting Flashcards

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

Method

A

A method is a reusable section of code written to perform a specific task in a program.

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

3 Reasons to Separate Code into Methods

A
  1. Better organization / Easier to Find & Fix bugs
  2. Makes code less redundant and more reusable
  3. Easier to work with objects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Separation of Concerns

A

Assigning specific tasks to individual methods

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

3 Parts of a Method

A
  1. Header - includes the def keyword (or { ), the method name, and any arguments the method takes
  2. Body - ode block that describes the procedures the method carries out
  3. End - all methods finish with the end keyword (or } )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to you call a method?

A

Just type its name in the code.

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

Splat Argument

A

Splat arguments are parameters that are preceded by a *

They allow for a wildcard number of inputs of the individual parameter

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