Try Git | Markdown Cheatsheet | Pro Git | Git Config
Getting Started
In the terminal start by creating a new directory, then run git init
to initialize a git repository
Fee = Struct.new(:percentage, :max, :min) | |
# # equivalent to | |
# class Fee | |
# attr_accessor :percentage, :max, :min | |
# def initialize(percentage, max, min) | |
# self.percentage = percentage | |
# self.max = max | |
# self.min = min | |
# end |
require 'spec_helper' | |
describe HomepageController do | |
describe "#index" do | |
it "is successful" do | |
get :index | |
expect(response).to be_success | |
end | |
end |
# What's the difference between procs and lambdas? | |
# | |
# To really understand the difference, put it to use. | |
# irb is great for this. | |
# In irb, instantiate a Lambda and a Proc | |
l = lambda {|x, y| x.times {puts y}} | |
p = Proc.new {|x, y| x.times {puts y}} | |
# See that they are both of the same class |
%fieldset.answer | |
= f.label :title | |
= f.text_field :title | |
= f.label :body | |
= f.text_field :body | |
= f.check_box :_destroy | |
= f.label :_destroy | |
%br |
Try Git | Markdown Cheatsheet | Pro Git | Git Config
Getting Started
In the terminal start by creating a new directory, then run git init
to initialize a git repository
1.) Ask user for a number then print out the number multiplied by 5 and then the same number added to itself
# Ask user for a number then print out the number multiplied by 5 and then the same number added to itself
puts "enter a num"
answer = gets.chomp.to_i
puts "The number: #{answer} The number multiplied by 5: #{(answer*5)+answer}"
Before object oriented programming, there was what's called 'Procedural Programming'. If I wanted to describe the mundane takss of my day to day routine, I could do so using procedures, such as "I wake up. I brush my teeth, etc."
However, we as humans tend to think of everything as an object. This is why languages like Ruby take objects to the extreme by making everything objects. Object oriented programming is good, because it makes thing easier to understand, and easier to extend. I can just include a library and have access to many more objects and methods.
I get into a car, which is an object. I turn on the car, which is a method on the object. Object interacting with each other is what OOP is all about.
Most modern languages are object oriented. Php, Java, Scala, etc.
Some Differences between a Class and an Object