-
Review of Rails Scopes & Namespacing
namespace :admin do resources :reviews, only: [:index] end
ARGV
is a convention in programming which refers to the “argument vector,” in basic terms a variable that contains the arguments / parameters passed to a program through the command line.
Typically an array with contains each argument in a certain position within the array. This may work differently in languages other than Ruby.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mergesort(array) | |
if array.count <= 1 | |
# Array of length 1 or less is always sorted | |
return array | |
end | |
# Apply "Divide & Conquer" strategy | |
# 1. Divide | |
mid = array.count / 2 |
A class in a formal classist language can be an object, but it’s a special kind of object with special properties and methods. It is responsible for creating new instances and for defining the behaviour of instances.
class SmartShoe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: | |
# for basic data structures such as strings, boolean and integers, | |
# please have a look at week 1 day 2 lecture notes | |
#################################################################### | |
# ARRAYS: lists of things | |
# an array of names | |
names = ["Faisal", "Sara", "Jane"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative('./vehicle') | |
class Car < Vehicle | |
attr_reader :wheels | |
def initialize(title, capacity, make_year, color, fuel_type, wheels) | |
# remember: calling `super` alone will use the same set of parameters | |
# being passed into the current initialize when calling the parent's initialize | |
super(title, capacity, make_year, color, fuel_type) | |
@wheels = wheels |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cellphone < Product | |
def initialize(name, price, brand) | |
super | |
end | |
end |
In the code below, is person is an Object or Class or Constructor? What's the difference ?
function Person(name,age) {
this.name = name;
this.age = age;
}
// a function that prints the name of any given person
var printPersonName = function (p) {