Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paul Haddick #179

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open

Paul Haddick #179

wants to merge 42 commits into from

Conversation

phdd0
Copy link

@phdd0 phdd0 commented Dec 18, 2021

My completed M1 Prework...

Copy link

@philmccarthy philmccarthy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @phdd0, I just had a chance to go over your prework and you are officially Turing Ready!

I added some comments to a few sections for areas to work on or adjustments to make before starting Mod 1 and put a little extra into your class exercises. Hope this helps bring some clarity, but you're doing great and a lot of this will become clearer as you get into Mod 1.

Keep up the hard work moving forward and let me know if you have any questions.

sidekicks = ["CricketCraig", "AntAndy", "RoachRalph"]

puts "#{sidekicks[0]}"
puts "#{arch_enemies[2]}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interpolation is redundant here. puts sidekicks[0] alone would return a string

puts "assess_situation(9, save_the_day, bad_excuse)"
assess_situation(9, save_the_day, bad_excuse)

scary_monster = { "name" => "Heffalump", "smell" => "Atrocious", "weight" => 1000000, "cities_destroyed" => ["carthage", "babel", "memphis"], "lucky_numbers" => [7, 5, 3, 9, 13, 119], "address" => { "number" => 221, "street" => "Long Windy Lane", "state" => "CO", "zip" => "88888" }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please work on formatting hashes with line breaks and indentation. A long, one-line hash isn't very kind to other developers who read your code 😉

def initialize(name, super_power, age)
@@name = name
@@super_power = super_power
@@age = age

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single @ for instance variables. You'll learn more about the @@ class variable syntax in Mod 1, but feel free to do some research into why class variables aren't appropriate in this example! You'll also find some good commentary on why class variables can lead to unintended behavior in Ruby.

But word to the wise: you shouldn't need to use class variables at all in Mod 1.

# respectively once spawned but the name, super power and age dynamic class variables are
# assigned by argument when calling Class.new
# Really then the only 'hard' part was really figuring out how to make the methods work with
# variable referencing

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may have conflated the exercise's dynamic reference with affecting all instances of a class, I'm not exactly following where you took this.

In this exercise, a dynamic attribute should only be dynamic for the instance of the class you are creating. Both dynamic and static attributes for an instance of SuperHero would be assigned as instance variables (@ not @@).

# args are (1, 1, range); if the test fails then Ruby checks whether it was ONLY
# the first arg OR (exclusively) the second that has zero remainder printing
# corresponding output in those cases, in case no test returns true Ruby will just
# print out the range index

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the else statement prints i (a number from the range, not index) if the previous conditionals are false

You took this in some interesting directions though, love that you're thinking about edge cases so early. But in this exercise, I would've liked to see you focus on the test cases as they were written instead of changing them to floats.


def change_protein
protein_prev = protein
protein = "Beef"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would need to be @protein to change the attribute

### variable scheme TBD to optimally model burrito changes

def add_topping
toppings = toppings_prev_add

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NameError (undefined local variable or method `toppings_prev_add' for #<Burrito:0x00007fdb2a975ec0>)

assignment is backwards

def add_topping
toppings = toppings_prev_add
puts "this is toppings now:" + "#{toppings}" + " and this is the previous toppings: #{toppings_prev_add} in a new variable"
toppings += ["sour cream"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would need to be @toppings to change the attribute

@@ -19,6 +19,13 @@ def bark
def eat
@hungry = false
end

def play
@hungry = true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice—here we're changing the @hungry instance variable (attribute).

Good example to compare to methods in the Burrito exercise that aren't altering instance variables

* As in my burrito_broaden.rb file I'm not sure about results I was getting attempting to do things inside class (instance) methods
* I'm still not clear at all at how the syntax in particular conveys the ideas expressed in the technical language about what the code is doing
* If someone were to walk me thorough how all of this particular syntax expresses the underlying structure of class and variables and methods accessible at various levels I imagine I'd understand more clearly

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully my explanations help out a bit with this. You're doing great, and you're right on track with figuring this stuff out, and I appreciate the amount of effort you're putting in. Keep up the great work in Mod 1 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants