Giter Site home page Giter Site logo

mutability-quiz-seattle-web-060319's Introduction

Quiz: Understanding Mutability

Objectives

  1. Strengthen your understanding of method scopes.
  2. Strengthen your understanding of mutability in Ruby.

???

Mutability Challenge

?: We have the following method that takes in an argument of an array and a string:

def quiz_method(array, object)
  array << object
end

If we call the method in the following manner:

array = ["hi", "there"]

quiz_method(array, "quizmaster")

What is the variable array now equal to?

( )["hi", "there"] (X)["hi", "there", "quizmaster"]

?: If we execute the same method in the following manner:

array = [1, 2, 3]
quiz_method(array, 4)

What is the array variable now equal to?

(X)[1, 2, 3, 4] ( )[1, 2, 3]

?: If we perform the following:

string = "hi there "
string << "quizmaster!"

What is the value of string?

( )"hi there" (X)"hi there quizmaster!"

?: What is the return value of the following method call?

array = [1, 2, 3, 4]
array.each do |num|
  num * 2
end

(X)[1, 2, 3, 4] ( )[2, 4, 6, 8]

?: Below we have a method that accepts two arguments of two numbers:

def change_the_number(num1, num2)
  num1 = num1 + num2
end

If we call it in the following way:

number_one = 5
number_two = 3
change_the_number(number_one, number_two)

What is the value of number_one?

(X)5 ( )8

???

View Quiz: Understanding Mutability on Learn.co and start learning to code for free.

mutability-quiz-seattle-web-060319's People

Contributors

maxwellbenton avatar evansjwang avatar sarogers avatar annjohn avatar rrcobb avatar sophiedebenedetto avatar markedwardmurray avatar

Watchers

 avatar Mohawk Greene avatar Victoria Thevenot avatar Bernard Mordan avatar Otha avatar raza jafri avatar  avatar Joe Cardarelli avatar The Learn Team avatar  avatar  avatar Matt avatar Antoin avatar  avatar Alex Griffith avatar  avatar Amanda D'Avria avatar  avatar Ahmed avatar Nicole Kroese  avatar Kaeland Chatman avatar Lisa Jiang avatar Vicki Aubin avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.