CodeNewton
Learn Ruby
Learn Ruby by actually writing Ruby code
Table of Contents
Reset Course Progress
1
Getting started
1.1
All you need is a working internet connection
1.2
Let us know what you think of CodeNewton
1.3
Jumping between pages
1.4
Next & Previous page using keyboard
1.5
Running code using keyboard
2
Puts for printing
2.1
I love ice cream
2.3
Simple math
3
String
3.1
Concatenating string
3.3
reverse to reverse string
3.5
upcase to convert string in capital letters
3.7
downcase to convert string in lowercase letters
3.9
strip to remove extra whitespaces
3.10
to_s to convert a number into a string
3.12
to_i to convert a string into a number
3.14
capitalize to convert only the first letter into capital letters
3.15
Method Chaining
3.17
First position is zero not 1
3.19
Last position is -1
3.21
start_with?
3.23
include? to check if a string is included or not
3.25
chars to convert string to characters
3.27
Interpolation using double quoted string
3.29
What is escape sequence
4
Array
4.1
Print items I like
4.2
each to handle each item of the array
4.4
Use each to double the number
4.7
length to find the count of items in the array
4.9
length and to_s to print count of items I like
4.11
reverse to reverse items in an array
4.13
push to add an item to an array
4.18
Get item from a position
4.21
Get a subset of the string
5
Variables
5.1
Using variable
5.2
Variables to add numbers
5.3
Variable names
5.4
Variable scope
5.6
Comment
5.7
Variable assignment is not working
5.8
Why spaces in variable assignment
6
Split string into array
6.1
split to split a string into an array
6.3
Split string along comma
6.8
join to convert an array into a string
7
If Else
7.1
if condition
7.3
if else condition
7.5
If else with multiple conditions
7.7
Using elsif
7.9
String vs Integer
7.10
Difference between = and ==
7.11
Inline if condition
7.12
ternary operator
8
Range
8.1
each to print value of each item
8.3
include? to find if value is in the range
8.6
to_a to convert range into array
8.7
Double dot vs Triple dot
9
Hash
9.1
Key Value Pair
9.3
Get value using key
9.6
merge! to add more data to hash
9.8
Add to hash using key directly
9.10
keys to list all keys
9.12
each to list all key and values
10
Assessments
10.1
Calculate grade using if and else
10.2
Calculate grade using range
10.3
Properly format Google office address
10.4
Properly format person info
10.5
Build multiplication table
10.6
Build Pizza Price Calculator
10.7
Find cities with the highest amount of rain
11
Number
11.1
times to loop over items
11.3
even? and odd? methods to check if the number is even or odd
11.4
optional underscore
12
What is nil
12.1
What is nil
12.2
nil is like false
13
Symbol
13.1
What is symbol
13.2
to_sym to convert a string into a symbol
13.3
to_s to convert a symbol into a string
14
Array
14.1
select to select certain items from array
14.4
reject to remove certain items from array
14.7
Using double arrow to add an item to an array
14.8
Concatenation
14.9
compact to remove all nil elements
14.10
uniq to remove all duplicate elements
14.11
flatten to remove all arrays
14.12
Removing elements from array using minus sign
14.13
Destructuring
14.14
Creating new array using percentage syntax
14.15
each_with_index to iterate of items using index
14.17
sort to sort items of array
15
Hash
15.1
Use new to create a hash
15.2
select to select some elements of the hash
15.4
reject to remove some elements from the hash
15.6
Default value in hash using default
15.8
Default value in hash using new
15.9
merge to add more data to hash
16
Comments
16.1
Single line comment
16.2
Multiple line comments
17
Regular expressions
17.1
\d to match any digit
17.2
\d to match any digit more examples
18
Assessments
18.1
Find all cities with high rain
18.2
Print names in a consistent manner
18.3
Print the shorter version of the name
19
Class
19.1
Car maker class definition
19.2
Coffee maker class definition
19.3
Biscuit producer class definition
19.4
Many instances of a class
19.5
What is your class
19.7
What is the class of String and Integer
20
Instance Method
20.1
Instance methods on car
20.2
Instance methods on coffee
20.3
Instance methods on biscuit
20.4
Instance method only work on instances
20.5
Biscuit as a gift
20.6
Turn the car
20.7
Hot coffee Cold Coffee
20.8
Multiple arguments
21
Instance Variable
21.1
Is my coffee hot or cold
21.2
Direction of car
22
Initialize Method
22.1
Initializer in Coffeemaker
22.2
Initializer in Carmaker
22.3
Fahrenheit to Celsius Converter
22.4
Pound to Kilogram converter
22.5
Yards to Metere converter
23
Required and default arguments
23.1
Required argument in initialize
24
attr_reader writer and accessor
24.1
Method to return instance variable
24.2
Using attr_reader exercise
24.3
Using attr_reader
24.4
Method to return instance variable
24.5
Method to set instance variable
24.6
Using attr_reader
24.7
Method to set and get instance variable
24.8
Using attr_reader
25
Blocks, Procs and Lambda
25.1
Ruby blocks introduction
25.2
Ruby blocks accepting arguments
25.3
Yield
25.4
Call block
25.5
Proc & Lambda
26
Module
26.1
Module
26.2
Last module wins
26.3
Modules are not copy paste