Skip to content

Instantly share code, notes, and snippets.

@laurenhavertz
Last active December 18, 2015 15:49
Show Gist options
  • Save laurenhavertz/5806909 to your computer and use it in GitHub Desktop.
Save laurenhavertz/5806909 to your computer and use it in GitHub Desktop.
WDI Action Adventure
  • If you're getting an error message then the installation of the program wasn't successful. If not, close and and reopen Terminal

  • When looking to change the environment an easy trick is to go to system preferances and use finder => this will spotlight where the system preferance is located.

  • Setting a default text editor :

    • Find a written code document
    • right click to get info
    • choose your editor of preference in open with
    • then choose change all

Booleans: *true, false *true, everything else => false *flase, nil => false

Conditionals & loops: *if, unless

Methods (functions): *verb *capability *stores a piece of code so have the ability to reuse it

  • each_slice : Iterates the given block for each slice of (n) elements. If no block is given, returns an enumerator.

  • shuffle! : the "bang" or "!" keeps the shuffle command permanent

  • string :anything in double quotes (word, sentance)

  • array : anything with square brackets on both sides *ordered storage container *object *operate on many things at a time (shuffle, slice) - example:["Travis", "Megan", "Bryan", "Theo"] <= literal array and JSON array *will get the same array in any language on any computer

JSON: Java Script Object Notation

language: language core: always going to have modules, language spec: built in part of the language

array_shuffle.rb
class Array
     def shuffle!
      #loop logic
        self[x] = self [y]
       end
      end
      
 ["Travis", "Megan", "Bryan", "Theo"]```
 
 **Good Resource: Ruby-docs.org**
 
 `to.json` :taking the way that the array prints and saving it to a file. No need to copy and paste. 
 
    File.open("my-stuff.puts", "w") { |f|
       f.write(puts(names))
       }
       
       `.length`: shows how long the string is 
       `.reverse`: reverses the string
       `.capitalize`: capitalizes the first letter of every word
       `.upcase`: makes the entire string in capital letters
       .inspect: inspect what is inside the variable
       .class: tells you what class it is
       [-n]: goes backward through the string
       
       
# Best Practices
variable names : use_under_score
use something self descriptive: array_of_students

= : assign
== : equal

*nil and false are the only thing that evaluate to `false` 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment