SlideShare a Scribd company logo
Ruby-Cheatsheet
A beginner's guide to learning Ruby
github.com/lifeparticle/Ruby-Cheatsheet
HI!
"ZAMAN".capitalize
Zaman
TABLEOFCONTENTS
Ruby talk
int [] a = {12,45,56,35};
for (int n : a) {
System.out.println(n);
}
[12,45,56,35].each { |n| puts n }
puts [12,45,56,35].join("n")
[12,45,56,35].each do |n|
puts n
end
numbers = [2, 2, 2, 2,
2]
sum = 0
for value in numbers
sum += value
end
puts sum
numbers = [2, 2, 2, 2,
2]
puts numbers.reduce(:+)
def sum (a, b)
10
end
sum 5, 5
def sum (a, b)
a + b
end
sum 5, 6
def sum (a, b)
return a + b
end
sum 5, 6
['a','e','i','o','u'].include? 'a'
true
name = "ZAMAN"
name.downcase
puts "#{name}"
ZAMAN
name.downcase!
puts "#{name}"
zaman
numbers = [*1..10]
[1, 2, 3, 4, 5, 6,
7, 8, 9, 10]
range = 1...10
range.to_a
[1, 2, 3, 4, 5, 6,
7, 8, 9]
range = 1..10
range.cover?(5)
true
range = 1..10
range.to_a
[1, 2, 3, 4, 5, 6,
7, 8, 9, 10]
def method_name(floors, *values)
# evaluate business logics
floors.reduce(:+)
end
method_name([5, 2, 6, 87], "alarm alarm", "false alarm")
method_name([1, 1, 1, 1, 1, 1, 1, 1, 1], "not a drill")
temp = 19
if temp >= 25
puts "hot"
elsif temp < 25 && temp >= 18
puts "normal"
else
puts "cold"
end
name = "rob"
unless name == "bob"
puts "hello stranger"
else
puts "hello bob"
end
count = 1
puts "hello world" if count == 1
Does anyone have any questions?
mahbub.ninja
THANKS

More Related Content

PDF
Clock For My
PDF
Demystifying Software Interviews
PDF
Data structure programs in c++
PDF
Python 1 liners
DOCX
C programs
DOCX
Experement no 6
PDF
A gentle introduction to functional programming through music and clojure
PDF
How To Crack RSA Netrek Binary Verification System
Clock For My
Demystifying Software Interviews
Data structure programs in c++
Python 1 liners
C programs
Experement no 6
A gentle introduction to functional programming through music and clojure
How To Crack RSA Netrek Binary Verification System

What's hot (16)

PDF
VTU Network lab programs
PDF
Merge sort
DOCX
DOCX
Numerical Method Assignment
PDF
Graph Algebra
DOCX
Assignement c++
PDF
Understanding the nodejs event loop
DOCX
Warna rgb
DOC
Data structure
DOCX
Solutionsfor co2 C Programs for data structures
PDF
benpresentation_django
PDF
1 borland c++ 5.02 by aramse
TXT
/Root/exam unidad1/muestraip red
PDF
Effective approaches to attention based neural machine translation
PDF
Enjoyable Front-end Development with Reagent
PDF
Jsr310 - Java 8 Date and Time API
VTU Network lab programs
Merge sort
Numerical Method Assignment
Graph Algebra
Assignement c++
Understanding the nodejs event loop
Warna rgb
Data structure
Solutionsfor co2 C Programs for data structures
benpresentation_django
1 borland c++ 5.02 by aramse
/Root/exam unidad1/muestraip red
Effective approaches to attention based neural machine translation
Enjoyable Front-end Development with Reagent
Jsr310 - Java 8 Date and Time API
Ad

Similar to Ruby talk (20)

PDF
Functional Programming with Groovy
KEY
Introduction to Groovy
PDF
Rainer Grimm, “Functional Programming in C++11”
PDF
PDF
[SI] Ada Lovelace Day 2014 - Tampon Run
PDF
CoffeeScript
PPTX
07012023.pptx
PDF
Voce Tem Orgulho Do Seu Codigo
PDF
Are we ready to Go?
PPTX
funwithalgorithms.pptx
PPTX
Groovy puzzlers по русски с Joker 2014
KEY
Haskellで学ぶ関数型言語
PPTX
Groovy puzzlers jug-moscow-part 2
DOCX
Hangman Game Programming in C (coding)
PDF
Damn Fine CoffeeScript
PDF
PDF
[EN] Ada Lovelace Day 2014 - Tampon run
PDF
Useful javascript
PDF
The Ring programming language version 1.2 book - Part 79 of 84
Functional Programming with Groovy
Introduction to Groovy
Rainer Grimm, “Functional Programming in C++11”
[SI] Ada Lovelace Day 2014 - Tampon Run
CoffeeScript
07012023.pptx
Voce Tem Orgulho Do Seu Codigo
Are we ready to Go?
funwithalgorithms.pptx
Groovy puzzlers по русски с Joker 2014
Haskellで学ぶ関数型言語
Groovy puzzlers jug-moscow-part 2
Hangman Game Programming in C (coding)
Damn Fine CoffeeScript
[EN] Ada Lovelace Day 2014 - Tampon run
Useful javascript
The Ring programming language version 1.2 book - Part 79 of 84
Ad

More from Lifeparticle (12)

PDF
Tech Talk: App Functionality (Android)
PDF
Android security and parsing 101
PDF
All about android
PPTX
Android SMS (GDayX, Dhaka, Bangladesh)
PDF
WorkShop on Arduino
PDF
Command line
PDF
Buacm 2
PDF
Buacm 3
PDF
Buacm 1
PDF
Graph theory
PDF
Icpc team registration guide for coach
PDF
Workshop on python
Tech Talk: App Functionality (Android)
Android security and parsing 101
All about android
Android SMS (GDayX, Dhaka, Bangladesh)
WorkShop on Arduino
Command line
Buacm 2
Buacm 3
Buacm 1
Graph theory
Icpc team registration guide for coach
Workshop on python

Recently uploaded (20)

PPTX
L1 - Introduction to python Backend.pptx
PDF
Nekopoi APK 2025 free lastest update
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
Introduction to Artificial Intelligence
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
medical staffing services at VALiNTRY
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
System and Network Administraation Chapter 3
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
L1 - Introduction to python Backend.pptx
Nekopoi APK 2025 free lastest update
Designing Intelligence for the Shop Floor.pdf
Introduction to Artificial Intelligence
Softaken Excel to vCard Converter Software.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
CHAPTER 2 - PM Management and IT Context
How to Choose the Right IT Partner for Your Business in Malaysia
medical staffing services at VALiNTRY
Understanding Forklifts - TECH EHS Solution
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Which alternative to Crystal Reports is best for small or large businesses.pdf
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Design an Analysis of Algorithms I-SECS-1021-03
Computer Software and OS of computer science of grade 11.pptx
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Reimagine Home Health with the Power of Agentic AI​
System and Network Administraation Chapter 3
Internet Downloader Manager (IDM) Crack 6.42 Build 41
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf

Ruby talk

  • 1. Ruby-Cheatsheet A beginner's guide to learning Ruby github.com/lifeparticle/Ruby-Cheatsheet
  • 5. int [] a = {12,45,56,35}; for (int n : a) { System.out.println(n); } [12,45,56,35].each { |n| puts n } puts [12,45,56,35].join("n") [12,45,56,35].each do |n| puts n end
  • 6. numbers = [2, 2, 2, 2, 2] sum = 0 for value in numbers sum += value end puts sum numbers = [2, 2, 2, 2, 2] puts numbers.reduce(:+)
  • 7. def sum (a, b) 10 end sum 5, 5 def sum (a, b) a + b end sum 5, 6 def sum (a, b) return a + b end sum 5, 6
  • 8. ['a','e','i','o','u'].include? 'a' true name = "ZAMAN" name.downcase puts "#{name}" ZAMAN name.downcase! puts "#{name}" zaman
  • 9. numbers = [*1..10] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] range = 1...10 range.to_a [1, 2, 3, 4, 5, 6, 7, 8, 9] range = 1..10 range.cover?(5) true range = 1..10 range.to_a [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  • 10. def method_name(floors, *values) # evaluate business logics floors.reduce(:+) end method_name([5, 2, 6, 87], "alarm alarm", "false alarm") method_name([1, 1, 1, 1, 1, 1, 1, 1, 1], "not a drill")
  • 11. temp = 19 if temp >= 25 puts "hot" elsif temp < 25 && temp >= 18 puts "normal" else puts "cold" end name = "rob" unless name == "bob" puts "hello stranger" else puts "hello bob" end count = 1 puts "hello world" if count == 1
  • 12. Does anyone have any questions? mahbub.ninja THANKS