Skip to content

Instantly share code, notes, and snippets.

@sjmog
Last active April 22, 2020 10:06
Show Gist options
  • Save sjmog/fa1d171f5a68d211c5ae921815786b43 to your computer and use it in GitHub Desktop.
Save sjmog/fa1d171f5a68d211c5ae921815786b43 to your computer and use it in GitHub Desktop.
Misconception: Parameter names and argument names must be the same

Misconception: "Parameter names and Argument names must be the same"

True or false: "parameter names and argument names must be the same"?

Play with the following examples: changing the names of the parameters and the arguments.

As always, try to have a hypothesis for what will happen before you make a change.

Ruby Example

def greet(name)
  return "Hi " + name
end

# Should this work?
name = "Mary"
greet(name)

# Should this work?
first_name = "Mary"
greet(first_name)

JavaScript Example

function greet(name) {
  return "Hi " + name;
};

// Should this work?
var name = "Mary";
greet(name);


// Should this work?
var firstName = "Mary";
greet(firstName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment