Skip to content
This repository has been archived by the owner on Jul 31, 2022. It is now read-only.

Added new content #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ install ruby dengan perintah `sudo apt-get install ruby`
* Arrays
* Code Blocks
* Ranges
* Iterator
* Regular Expressions
* Symbols
* Hashes
* Date & Time

## Session 2: OOP with Ruby

Expand All @@ -44,6 +46,7 @@ install ruby dengan perintah `sudo apt-get install ruby`
* Classes as Objects
* Metaprogramming
* I/O
* Multithreading

## Session 4: Testing

Expand Down
12 changes: 12 additions & 0 deletions Session1.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,18 @@ else
end
```

## Iterator
Iterator merupakan salah satu fitur yang didukung oleh collections dalam ruby. collections merupakan object yang menyimpan sekumpulan data, seperti array dan hashes.

```
array = ["a", "b", "c", "d"];
array.each do |i|
puts i
end
```

Tiap nilai dari array disimpan dalam i dan ditampilkan ke console melalui puts.

## Regular Expressions

_Regular Expression_ dalam ruby ditangani oleh kelas `Regexp`.
Expand Down
40 changes: 40 additions & 0 deletions Session3.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,43 @@ end unless file.closed?

file.close
```

## Multitreading

Program multithreading adalah program yang memiliki banyak thread yang dieksekusi.
Dalam thread tiap block code dieksekusi secara sequential tapi thread sendiri bisa dieksekusi secara parallel dalam multicore cpu.

cara membuat thread di ruby:
Thread.new

cara membuat multithreading :

```ruby
#!/usr/bin/ruby

def func1
i=0
while i<=3
puts "func1"
sleep(1)
i=i+1
end
end

def func2
j=0
while j<=3
puts "func2"
sleep(2)
j=j+1
end
end

t1=Thread.new{func1()}
t2=Thread.new{func2()}
t1.join
t2.join
puts ""
```

selengkapnya di : https://www.tutorialspoint.com/ruby/ruby_multithreading.htm