Skip to content

Instantly share code, notes, and snippets.

@stellakunzang
Created April 17, 2020 17:23
Show Gist options
  • Select an option

  • Save stellakunzang/23086afe6daececf13a7d9002da7b562 to your computer and use it in GitHub Desktop.

Select an option

Save stellakunzang/23086afe6daececf13a7d9002da7b562 to your computer and use it in GitHub Desktop.
CFU 04-17-2020

Call Stack CFU

  1. What is the check_it algorthim checking?

It is checking if each opening and closing bracket, paranethesis, or curly brace in a pair are present, by setting the opening character as a key and the closing character as a value in the open_close method. It returns true or false based on whether both in the pair are present and nested properly.

  1. What other applications could this algorithm have?

This algorithm might be what is underlying the errors that Ruby returns (and the linter detects in atom) when we forget to use close all of our hashes and arrays and nested stuff properly.

  1. What kinds of problems are Stacks good at?

Carrying out actions in the proper order. Otherwise it would be mayhem!

Ruby Object Model

  1. Classes are containers for what? Behaviors. Instructions for an object to be able to understand.

  2. Classes have a pointer to what? Superclasses

  3. Instances are containers for what? Instance variables.

  4. Instances have a pointer to what? Class

  5. We say classes are also instances... what does this mean? A class is an instances of the Object class.

  6. Method parameters are what kind of variable? local variables

  7. All code executes in what? call stack

  8. What are the bindings? "A ruby class that captures the context in which code is executed"

  9. Bindings are containers for what? variables, methods, self, and other contextual information

  10. Bindings execute in what? call stack

  11. Bindings have a pointer to what? Whatever their context is? Could be a method, and instance, a class...

  12. What does this give them access to? Whatever is within their scope

  13. Where are methods stored? Classes

  14. If I call a method on an instance, where does it look for the method? In the class

  15. What if it doesn't find the method there? In the superclass

  16. What if it STILL doesn't find the method there? In the superclass of that class

  17. What does it do once it finds the method? executes

  18. I call "hello world".upcase; what is self inside of the upcase method? the string "hello world"

  19. What is the colloquial term for an instance? a specific instance

  20. In the code below, which describes what is actually happening?
    a = "some string". b = a

a and b are local variables pointing to the same string a is a local variable, b is an alias, pointing to a different string a and b are local variables, each pointing to their own instance of "some string" a is pointing to "some string", and b is pointing to a

  1. What is abc?

a string a symbol an instance variable a local variable

  1. What is @abc? a local variable a constant an instance variable a global variable

  2. What is Abc? a local variable a constant an instance variable a global variable

  3. What is $abc? a local variable a constant an instance variable a global variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment