SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Lets
start coding
with
Ruby
I’m
Muntasim Ahmed
Developer @globo
ishkul.com
https://github.com/amuntasim/
https://www.linkedin.com/in/muntasim/
Web Developers?
#include <stdio.h>
int main(){
printf(“I love C!”) /*seriously!!*/
return 0;
}
public class BigBrother{
public static void main(String[] args) {
String msg=“Hello!! Here is your big brother”
System.out.println(msg);
}
}
puts “its really simple! ”
class RubyClass
attr_accessor :v1, :v2
end
r = RubyClass.new
r.v1 = “test”
r.v1 => ‘test’
r.v2 => nil
Thank you Matz!
Ruby Philosophie
“I believe people want to express themselves
when they program. They don’t want to fight
with the language. Programming languages
must feel natural to programmers. I tried to
make people enjoy programming and
concentrate on the fun and creative part of
programming when they use Ruby.”
-- Yukihiro "Matz" Matsumoto, Ruby creator
Why Ruby?
• Its simple
• Easy to write/learn
• Truly object oriented
• Emphasize programming speed!
• Less code, fewer bugs
• Open source
From where to start?!
Installation
• Just google with install ruby with
rvm/rbenv in <Your OS>
• Should be simple as like Ruby 
From where to start?!
IRB = Interactive Ruby
> Irb
Or
tryruby.org
Inside Ruby
Everything is an object
3.odd? => true
“string”.length => 6
[].empty? => true
“abc”.methods => [..,..,..]
Duck Typing
?!
It doesn’t mind
• if you don’t like ‘;’ at the end
• even a method without ()
• If you want to express in your way
• and many more..
Happy Programmer 
Variables
• Any plain, lowercase word
• a, my_variable and rubyconf2017
• > a => undefined local variable or method `a`
• > a = ‘hello’ => hello
• > a => hello
• > a = 1 => 1 
Number
• Integers (Fixnum), Float
• 1, -3002, 2.3, 1233.1e12
• > 1.class => Fixnum
• >1.3.class => Float
• >1.3e12.class => Float
• >1 + 2 => 3
• >1.4+ 4 => 5.4
Strings
• Anything surrounded by quotes ‘’ or “”
• ‘RubyConf 2017’, “Muntasim”
• > a = ‘hello’ => hello
• > a => hello
• > a.upcase => HELLO
• > a.upcase.object_id => 2212289940
• > a.object_id => 2212352200
• > a << ‘ world’ => hello world
Symbols
• Start with a colon, look like words
• Uses same object reference
• Useful for keys
• :test, :a
• >"test".object_id => 2212252220
• >"test".object_id => 2212236940
• > :test.object_id => 196968
• > :test.object_id => 196968
Constants
• variables, starts with a capital
• Foo, Conf_Date
• :test, :a
 Foo = ‘bar’ => bar
 Foo = ‘dum’ =>’dum’ #warning.
 if something == Foo
#do something
end
Methods
def hi
puts ‘Hi there!’
end
 hi => Hi there!
def hello(name)
puts “Hello #{name}!”
end
 hello ‘khoka’ => ‘Hi khoka!’
Arrays
• A list surrounded by square brackets
• [1,2,4]
• [‘a’, ‘B’, 1] 
 a = [1,3,5,’7’, ‘e’] => [1,3,5,’7’, ‘e’]
 a[2] => 3
 b = [5,6] => [5,6]
 a+b => [1,3,5,’7’, ‘e’, 5,6]
 ….
Hashes
• A list surrounded by curly braces
• {:a => 2, b: ‘3’}
 a = {:a => 2, b: ‘3’} => {:a => 2, b: ‘3’}
 a[:a] => 2, a[:b] => ‘3’
 a.keys => [:a, :b]
 ….
Classes
class Car
attr_accessor :wheels, :color
end
 c = Car.new => #<Car:0x00000107b09840>
 c2 = Car.new =>#<Car:0x00000107b00a60>
 c.color = ‘white’ => white
 c.color => white
 c2.color => nil
class Car
attr_accessor :wheels, :color
def initialize(wheels, color)
self. wheels = wheels
self. color = color
end
def color_and_wheels
“#{color} color with #{wheels} ‘wheels’)”
end
end
 c = Car.new(4, ‘white’) => #<Car0x00000b09840 .....>
 c.color_and_wheels => ‘white color with 4 wheels’
Classes (Open to modify)
class Bird
def make_sound
p “ka-ka-ka”
end
def color
p “black”
end
end
b = Bird.new
b.make_sound => ‘ka-ka-ka’
b.color => ‘black’
Classes (Open to modify)
class Bird
def make_sound
p “kuhu :D ”
end
def name
p “a name”
end
b = Bird.new
b.make_sound => ‘kuhu :D’
b.color => ‘black’
b.name => ‘a name’
Don’t like the sound? Just open the class and
modify it
Module
 Like classes, modules contain methods and
constants but don’t have instances.
 encourage modular design
 Ruby doesn’t support multiple inheritance
but can have that behavior by modules
Module
module M
def m1
end
end
module M
class C
end
end
M.new c = M::C.new
Module
class Thing < Parent
include MathFunctions
include Taggable
include Persistence
end
module Feature
def feature1
p ‘feature1’
end
def feature2
p ‘feature2’
end
end
module Habits
def habit1
p ‘habit1’
end
def habit2
p ‘habit2’
end
end
class Parent
def a1
p ‘a1’
end
end
class Thing < Parent
include Feature
include Habits
end
t = Thing.new
t.a1 => ‘a1’
t.feature1 => ‘feature1’
t.habit2 => ‘habit2’
More on Ruby Basics
• http://rubymonk.com/
• http://tryruby.org/
• http://rubykoans.com/
• http://ruby.learncodethehardway.org/
• http://poignant.guide/ (funny!)
Ruby eco system
• RVM/rbenv
• RubyGems
• Bundler
• Git/github
Ruby vs Ruby on Rails(aka Rails)
• Rails is written in the Ruby
• Rails uses many Ruby gems
• Rails is a framework
• Rails is used to build web apps
rubyonrails.org
Editors
• RubyMine
• Sublime Text
• Textmate
• Vim
• Emacs
• Or whatever you like
References:
• https://www.ruby-lang.org/en/
• https://dzone.com/refcardz/essential-ruby
• http://www.jasimabasheer.com/posts/meta_i
ntroduction_to_ruby.html
• http://curriculum.railsbridge.org/docs/

Weitere ähnliche Inhalte

Ähnlich wie Rubyconf Bangladesh 2017 - Lets start coding in Ruby

Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick touraztack
 
Desarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosDesarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosEdgar Suarez
 
Intro to Ruby - Twin Cities Code Camp 7
Intro to Ruby - Twin Cities Code Camp 7Intro to Ruby - Twin Cities Code Camp 7
Intro to Ruby - Twin Cities Code Camp 7Brian Hogan
 
Blocks by Lachs Cox
Blocks by Lachs CoxBlocks by Lachs Cox
Blocks by Lachs Coxlachie
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Wen-Tien Chang
 
Design Patterns the Ruby way - ConFoo 2015
Design Patterns the Ruby way - ConFoo 2015Design Patterns the Ruby way - ConFoo 2015
Design Patterns the Ruby way - ConFoo 2015Fred Heath
 
Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby MetaprogrammingThaichor Seng
 
Groovy presentation
Groovy presentationGroovy presentation
Groovy presentationManav Prasad
 
Ruby is Awesome
Ruby is AwesomeRuby is Awesome
Ruby is AwesomeAstrails
 
Write your Ruby in Style
Write your Ruby in StyleWrite your Ruby in Style
Write your Ruby in StyleBhavin Javia
 
How to make a large C++-code base manageable
How to make a large C++-code base manageableHow to make a large C++-code base manageable
How to make a large C++-code base manageablecorehard_by
 
Deep Dive Into Swift
Deep Dive Into SwiftDeep Dive Into Swift
Deep Dive Into SwiftSarath C
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingZain Abid
 
Automated Testing with Ruby
Automated Testing with RubyAutomated Testing with Ruby
Automated Testing with RubyKeith Pitty
 
Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Henry S
 

Ähnlich wie Rubyconf Bangladesh 2017 - Lets start coding in Ruby (20)

Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick tour
 
Desarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosDesarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutos
 
An introduction to Ruby
An introduction to RubyAn introduction to Ruby
An introduction to Ruby
 
Intro to Ruby - Twin Cities Code Camp 7
Intro to Ruby - Twin Cities Code Camp 7Intro to Ruby - Twin Cities Code Camp 7
Intro to Ruby - Twin Cities Code Camp 7
 
Designing Ruby APIs
Designing Ruby APIsDesigning Ruby APIs
Designing Ruby APIs
 
Ruby
RubyRuby
Ruby
 
Blocks by Lachs Cox
Blocks by Lachs CoxBlocks by Lachs Cox
Blocks by Lachs Cox
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手
 
Design Patterns the Ruby way - ConFoo 2015
Design Patterns the Ruby way - ConFoo 2015Design Patterns the Ruby way - ConFoo 2015
Design Patterns the Ruby way - ConFoo 2015
 
Intro to ruby
Intro to rubyIntro to ruby
Intro to ruby
 
Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby Metaprogramming
 
Groovy presentation
Groovy presentationGroovy presentation
Groovy presentation
 
Ruby is Awesome
Ruby is AwesomeRuby is Awesome
Ruby is Awesome
 
Write your Ruby in Style
Write your Ruby in StyleWrite your Ruby in Style
Write your Ruby in Style
 
How to make a large C++-code base manageable
How to make a large C++-code base manageableHow to make a large C++-code base manageable
How to make a large C++-code base manageable
 
Deep Dive Into Swift
Deep Dive Into SwiftDeep Dive Into Swift
Deep Dive Into Swift
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Automated Testing with Ruby
Automated Testing with RubyAutomated Testing with Ruby
Automated Testing with Ruby
 
Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2
 
Enumerables
EnumerablesEnumerables
Enumerables
 

Mehr von Ruby Bangladesh

RubyConf Bangladesh 2017 - Introduction to Ruby on Rails
RubyConf Bangladesh 2017 - Introduction to Ruby on RailsRubyConf Bangladesh 2017 - Introduction to Ruby on Rails
RubyConf Bangladesh 2017 - Introduction to Ruby on RailsRuby Bangladesh
 
RubyConf Bangladesh 2017 - Core Ruby: How it works
RubyConf Bangladesh 2017 - Core Ruby: How it worksRubyConf Bangladesh 2017 - Core Ruby: How it works
RubyConf Bangladesh 2017 - Core Ruby: How it worksRuby Bangladesh
 
RubyConf Bangladesh 2017 - Speed up your API/backend
RubyConf Bangladesh 2017 - Speed up your API/backendRubyConf Bangladesh 2017 - Speed up your API/backend
RubyConf Bangladesh 2017 - Speed up your API/backendRuby Bangladesh
 
RubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSL
RubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSLRubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSL
RubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSLRuby Bangladesh
 
RubyConf Bangladesh 2017 - Which language should I choose
RubyConf Bangladesh 2017 - Which language should I chooseRubyConf Bangladesh 2017 - Which language should I choose
RubyConf Bangladesh 2017 - Which language should I chooseRuby Bangladesh
 
RubyConf Bangladesh 2017 - Elixir for Rubyists
RubyConf Bangladesh 2017 - Elixir for RubyistsRubyConf Bangladesh 2017 - Elixir for Rubyists
RubyConf Bangladesh 2017 - Elixir for RubyistsRuby Bangladesh
 
RubyConf Bangladesh 2017 - Rails buggy code
RubyConf Bangladesh 2017 - Rails buggy codeRubyConf Bangladesh 2017 - Rails buggy code
RubyConf Bangladesh 2017 - Rails buggy codeRuby Bangladesh
 

Mehr von Ruby Bangladesh (7)

RubyConf Bangladesh 2017 - Introduction to Ruby on Rails
RubyConf Bangladesh 2017 - Introduction to Ruby on RailsRubyConf Bangladesh 2017 - Introduction to Ruby on Rails
RubyConf Bangladesh 2017 - Introduction to Ruby on Rails
 
RubyConf Bangladesh 2017 - Core Ruby: How it works
RubyConf Bangladesh 2017 - Core Ruby: How it worksRubyConf Bangladesh 2017 - Core Ruby: How it works
RubyConf Bangladesh 2017 - Core Ruby: How it works
 
RubyConf Bangladesh 2017 - Speed up your API/backend
RubyConf Bangladesh 2017 - Speed up your API/backendRubyConf Bangladesh 2017 - Speed up your API/backend
RubyConf Bangladesh 2017 - Speed up your API/backend
 
RubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSL
RubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSLRubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSL
RubyConf Bangladesh 2017 - Craft beautiful code with Ruby DSL
 
RubyConf Bangladesh 2017 - Which language should I choose
RubyConf Bangladesh 2017 - Which language should I chooseRubyConf Bangladesh 2017 - Which language should I choose
RubyConf Bangladesh 2017 - Which language should I choose
 
RubyConf Bangladesh 2017 - Elixir for Rubyists
RubyConf Bangladesh 2017 - Elixir for RubyistsRubyConf Bangladesh 2017 - Elixir for Rubyists
RubyConf Bangladesh 2017 - Elixir for Rubyists
 
RubyConf Bangladesh 2017 - Rails buggy code
RubyConf Bangladesh 2017 - Rails buggy codeRubyConf Bangladesh 2017 - Rails buggy code
RubyConf Bangladesh 2017 - Rails buggy code
 

Kürzlich hochgeladen

Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 

Kürzlich hochgeladen (20)

Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 

Rubyconf Bangladesh 2017 - Lets start coding in Ruby

  • 2.
  • 5. #include <stdio.h> int main(){ printf(“I love C!”) /*seriously!!*/ return 0; }
  • 6. public class BigBrother{ public static void main(String[] args) { String msg=“Hello!! Here is your big brother” System.out.println(msg); } }
  • 7. puts “its really simple! ” class RubyClass attr_accessor :v1, :v2 end r = RubyClass.new r.v1 = “test” r.v1 => ‘test’ r.v2 => nil
  • 9. Ruby Philosophie “I believe people want to express themselves when they program. They don’t want to fight with the language. Programming languages must feel natural to programmers. I tried to make people enjoy programming and concentrate on the fun and creative part of programming when they use Ruby.” -- Yukihiro "Matz" Matsumoto, Ruby creator
  • 10. Why Ruby? • Its simple • Easy to write/learn • Truly object oriented • Emphasize programming speed! • Less code, fewer bugs • Open source
  • 11. From where to start?! Installation • Just google with install ruby with rvm/rbenv in <Your OS> • Should be simple as like Ruby 
  • 12. From where to start?! IRB = Interactive Ruby > Irb Or tryruby.org
  • 13.
  • 15. Everything is an object 3.odd? => true “string”.length => 6 [].empty? => true “abc”.methods => [..,..,..]
  • 17. It doesn’t mind • if you don’t like ‘;’ at the end • even a method without () • If you want to express in your way • and many more.. Happy Programmer 
  • 18.
  • 19.
  • 20. Variables • Any plain, lowercase word • a, my_variable and rubyconf2017 • > a => undefined local variable or method `a` • > a = ‘hello’ => hello • > a => hello • > a = 1 => 1 
  • 21. Number • Integers (Fixnum), Float • 1, -3002, 2.3, 1233.1e12 • > 1.class => Fixnum • >1.3.class => Float • >1.3e12.class => Float • >1 + 2 => 3 • >1.4+ 4 => 5.4
  • 22. Strings • Anything surrounded by quotes ‘’ or “” • ‘RubyConf 2017’, “Muntasim” • > a = ‘hello’ => hello • > a => hello • > a.upcase => HELLO • > a.upcase.object_id => 2212289940 • > a.object_id => 2212352200 • > a << ‘ world’ => hello world
  • 23. Symbols • Start with a colon, look like words • Uses same object reference • Useful for keys • :test, :a • >"test".object_id => 2212252220 • >"test".object_id => 2212236940 • > :test.object_id => 196968 • > :test.object_id => 196968
  • 24. Constants • variables, starts with a capital • Foo, Conf_Date • :test, :a  Foo = ‘bar’ => bar  Foo = ‘dum’ =>’dum’ #warning.  if something == Foo #do something end
  • 25. Methods def hi puts ‘Hi there!’ end  hi => Hi there! def hello(name) puts “Hello #{name}!” end  hello ‘khoka’ => ‘Hi khoka!’
  • 26. Arrays • A list surrounded by square brackets • [1,2,4] • [‘a’, ‘B’, 1]   a = [1,3,5,’7’, ‘e’] => [1,3,5,’7’, ‘e’]  a[2] => 3  b = [5,6] => [5,6]  a+b => [1,3,5,’7’, ‘e’, 5,6]  ….
  • 27. Hashes • A list surrounded by curly braces • {:a => 2, b: ‘3’}  a = {:a => 2, b: ‘3’} => {:a => 2, b: ‘3’}  a[:a] => 2, a[:b] => ‘3’  a.keys => [:a, :b]  ….
  • 28. Classes class Car attr_accessor :wheels, :color end  c = Car.new => #<Car:0x00000107b09840>  c2 = Car.new =>#<Car:0x00000107b00a60>  c.color = ‘white’ => white  c.color => white  c2.color => nil
  • 29. class Car attr_accessor :wheels, :color def initialize(wheels, color) self. wheels = wheels self. color = color end def color_and_wheels “#{color} color with #{wheels} ‘wheels’)” end end  c = Car.new(4, ‘white’) => #<Car0x00000b09840 .....>  c.color_and_wheels => ‘white color with 4 wheels’
  • 30. Classes (Open to modify) class Bird def make_sound p “ka-ka-ka” end def color p “black” end end b = Bird.new b.make_sound => ‘ka-ka-ka’ b.color => ‘black’
  • 31. Classes (Open to modify) class Bird def make_sound p “kuhu :D ” end def name p “a name” end b = Bird.new b.make_sound => ‘kuhu :D’ b.color => ‘black’ b.name => ‘a name’ Don’t like the sound? Just open the class and modify it
  • 32. Module  Like classes, modules contain methods and constants but don’t have instances.  encourage modular design  Ruby doesn’t support multiple inheritance but can have that behavior by modules
  • 33. Module module M def m1 end end module M class C end end M.new c = M::C.new
  • 34. Module class Thing < Parent include MathFunctions include Taggable include Persistence end
  • 35. module Feature def feature1 p ‘feature1’ end def feature2 p ‘feature2’ end end module Habits def habit1 p ‘habit1’ end def habit2 p ‘habit2’ end end class Parent def a1 p ‘a1’ end end class Thing < Parent include Feature include Habits end t = Thing.new t.a1 => ‘a1’ t.feature1 => ‘feature1’ t.habit2 => ‘habit2’
  • 36. More on Ruby Basics • http://rubymonk.com/ • http://tryruby.org/ • http://rubykoans.com/ • http://ruby.learncodethehardway.org/ • http://poignant.guide/ (funny!)
  • 37. Ruby eco system • RVM/rbenv • RubyGems • Bundler • Git/github
  • 38. Ruby vs Ruby on Rails(aka Rails) • Rails is written in the Ruby • Rails uses many Ruby gems • Rails is a framework • Rails is used to build web apps rubyonrails.org
  • 39. Editors • RubyMine • Sublime Text • Textmate • Vim • Emacs • Or whatever you like
  • 40. References: • https://www.ruby-lang.org/en/ • https://dzone.com/refcardz/essential-ruby • http://www.jasimabasheer.com/posts/meta_i ntroduction_to_ruby.html • http://curriculum.railsbridge.org/docs/

Hinweis der Redaktion

  1. - deals with objects, not the classes. - If the object has the method, it can call the method
  2. - deals with objects, not the classes. - If the object has the method, it can call the method
  3. - deals with objects, not the classes. - If the object has the method, it can call the method
  4. - deals with objects, not the classes. - If the object has the method, it can call the method
  5. - deals with objects, not the classes. - If the object has the method, it can call the method
  6. - deals with objects, not the classes. - If the object has the method, it can call the method
  7. - deals with objects, not the classes. - If the object has the method, it can call the method
  8. - deals with objects, not the classes. - If the object has the method, it can call the method
  9. - deals with objects, not the classes. - If the object has the method, it can call the method
  10. - deals with objects, not the classes. - If the object has the method, it can call the method
  11. - deals with objects, not the classes. - If the object has the method, it can call the method
  12. - deals with objects, not the classes. - If the object has the method, it can call the method
  13. - deals with objects, not the classes. - If the object has the method, it can call the method
  14. - deals with objects, not the classes. - If the object has the method, it can call the method
  15. - deals with objects, not the classes. - If the object has the method, it can call the method
  16. - deals with objects, not the classes. - If the object has the method, it can call the method
  17. - deals with objects, not the classes. - If the object has the method, it can call the method
  18. - deals with objects, not the classes. - If the object has the method, it can call the method
  19. - deals with objects, not the classes. - If the object has the method, it can call the method
  20. - deals with objects, not the classes. - If the object has the method, it can call the method