Wednesday 18 January 2017

My Journey Of Learning Programming Through Flatiron School #7

flatiron school

My name is Mason Ellwood and I’m currently working on Flatiron School’s Online Full Stack Web Development Program. Each week, I’ll be writing about my experience, what I’m learning, and tips on learning to code.

It is funny to read and find SO many articles on the internet about how long does it take to learn to write code. Even Flatiron Schools talks about it.

The above video is great and you should watch it, but I always thought this heavily debated question was interesting to me. When I was in high school, we had to take two years of a language, being from Arizona, Spanish it was. Also being a high school student, damn you former self,  I did not want to learn, but float through. This being said I did not care to learn Spanish it was no interest to me, but a requirement. So I worked through the material, passed the class, and then moved on with my life. This is because, blatantly, I just did not care to learn it, it did not interest me. Learning Ruby or HTML or whatever is exactly like this. Even if you work through the material and at the end of the tunnel if you truly do not care and uninterested, then you most likely not you will not progress much further than what school has taught you. Just like me with Spanish. Programming disciplines are just another language, and it takes years to perfect and get right, just like spoken languages.

Find something that you care about, and take the time to learn, prepare, and want to be the best at. If you want to build… a shelf for instance, if you have never done it before and have never picked up a tool before, it is going to take you forever, and most likely it is going to look like garbage. But after working through that learning process, then your next shelf is going to look a heck of a lot better.
Logic and Conditionals:

 

This week we were learning about logic and conditionals, more specifically boolean values. Like I stated before, there is no such thing as a boolean value in Ruby, but values can equal to true or false. Booleans, if you forgot, equal true or false. This is not always the case, for instance in Python, which equals yes or no, but we won’t get into that. These come in very hand when you want to implement control flow.

Control flow is the idea that we can tell our program to execute certain lines of code based on certain conditions and are predicted on these true or false boolean values.

Within Ruby only false or nil are false, and everything else is considered thruthy including 0. Below are values that equal to either true or false.

  • Value
    • True
  • 0
    • True
  • ” ”
    • True
  • “hello”
    • True
  • Nil
    • False
  • 4.4
    • True
  • true
    • True
  • !true
    • False
  • false
    • False
  • !false
    • True
  • [2,2]
    • True
  • {:hi => “there”}
    • True

Remember the single bang operator ( ! ) will negate the boolean if it is placed in front of the value.

 

Placing a double bang operator ( !! ) will return true or false based on whether a value is truthy or falsey.

 

Booleans in Ruby are the true and false data type, defined as their own data type.

  • True is a Ruby programs instance of true class.
  • False is a Ruby programs instance of false class

Classes serve as templates for Ruby objects, which we will get into later.

Boolean Operators:

Boolean operators are really just methods which mean they have a return value which is either true or false. Three boolean operators are:

  • ! ( “single bang” ) which represents “not”
  • && ( “double ampersand” ) which represents “and”
  • || ( “double-pipe” ) which represents “or”

For && to evaluate to true, both values of either side of the symbols must evaluate true.

 

For || ( or ) to evaluate true only one value on either side of the symbol must evaluate to true.

Understanding booleans and what they do and how to use them will greatly benefit you in your programming career and are used almost in every instance. For further clarification please leave a comment below. For further reading that helped me please visit the LINK HERE.

Read More at My Journey Of Learning Programming Through Flatiron School #7



from Web Design Ledger https://webdesignledger.com/my-journey-of-learning-programming-through-flatiron-school-7/

No comments:

Post a Comment