Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ruby Basics
Search
Diego Guerra Suárez
March 04, 2015
Programming
82
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ruby Basics
Slides from the first day of the ruby@uniovi workshop
Diego Guerra Suárez
March 04, 2015
More Decks by Diego Guerra Suárez
See All by Diego Guerra Suárez
Reruby: Automated refactoring with Ruby
dgsuarez
0
180
Programas que se entienden a sí mismos
dgsuarez
0
92
Curando el bacilo enmiequipus funcionabilis
dgsuarez
1
190
Ruby on the Web
dgsuarez
0
73
Other Decks in Programming
See All in Programming
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
220
FastAPI の並行処理モデルを完全に理解する
hoto17296
1
260
Android CLI
fornewid
0
230
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
2k
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
520
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
110
バグを直したら useEffect が消えた
colorful12
3
660
yield再入門 #phpcon
o0h
PRO
0
1.2k
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
340
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
4.9k
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
500
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
350
Featured
See All Featured
WCS-LA-2024
lcolladotor
0
800
Faster Mobile Websites
deanohume
310
32k
Building AI with AI
inesmontani
PRO
1
1.1k
Balancing Empowerment & Direction
lara
6
1.2k
Utilizing Notion as your number one productivity tool
mfonobong
4
550
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
270
The Pragmatic Product Professional
lauravandoore
37
7.4k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
970
Visualization
eitanlees
152
17k
First, design no harm
axbom
PRO
2
1.3k
Transcript
Ruby Basics Ruby: from 0 to 100 in 14400 seconds
(1) ruby@uniovi: Introducing the Ruby programming language School of Computer Sciences University of Oviedo March 2015
Welcome aboard!
https://github.com/ruby-uniovi/rubyeii
git clone https://github.com/ruby-uniovi/rubyeii.git cd rubyeii vagrant up vagrant reload
None
Ruby
まつもとゆきひろ Yukihiro ‘Matz’ Matsumoto
But… why Ruby?
Fun
Principle of least astonishment
Poetry mode
Expressive > 3.times { print "Ho" } #=>"HoHoHo" > 151.even?
#=> false
Agile
Community
Matz is Nice And So We Are Nice a.k.a. MINASWAN
Basics
None
> 2.next #=> 3 (Fixnum)
class Dog def woof puts"Wooof woooof!" end end
> Dog.class #=> Class > Dog.method(:woof).class #=> Method
Modules
module Animals class Dog # … implementation … end end
module Playable def play # … implementation … end end
class Song include Playable end
Methods
def factorial(n) return 1 if n == 0 n *
factorial(n -1) end ❏ Ruby methods always return the result of their last evaluated expression. ❏ return is only used to break out of the method before its end.
Inheritance
module Animals class Dog < Animal # … implementation …
end end ❏ A class can only inherit from ONE other class ❏ There aren’t Abstract classes in Ruby (in contrast to Java)
Misc
def say_hello(name) puts "Hello #{name}!" end def say_hello name puts("Hello
#{name}!"); end ❏ In Ruby, parenthesis and semicolons are optional ❏ Both methods have valid syntax and are equivalent.
VAT = 0.04 total = begin sum = products.map(&:price).inject(&:+) sum
+= (sum * VAT) end In Ruby, you can assign the result of any expression as a variable value.