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
Whats up in Ruby 2.0
Search
Domas Bitvinskas
March 23, 2013
Programming
6
1.5k
Whats up in Ruby 2.0
A quick overview of the cool changes in Ruby 2.0 release.
Domas Bitvinskas
March 23, 2013
Tweet
Share
More Decks by Domas Bitvinskas
See All by Domas Bitvinskas
3 cool AI things
nedomas
0
38
Apollo & GraphQL: What we learned building a multi-platform chat app
nedomas
1
160
Best kept secrets for 2019: GraphQL + Prisma
nedomas
1
69
Tensorflow.js ir web ateitis
nedomas
1
100
Hack the Open Source Growth
nedomas
1
70
Market your Open Source or kill it
nedomas
1
850
Ruby on Rails is dead
nedomas
2
1.1k
Why does Ruby own the startup world?
nedomas
0
630
Rockstars and Productivity
nedomas
1
950
Other Decks in Programming
See All in Programming
MetricKitで予期せぬ終了を検知する話 / Detect unexpected termination with MetricKit
nekowen
1
200
大規模Reactアプリのリアーキテクチャ~8万行のTanStack Query移行の軌跡~
kj455
4
1k
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
380
はてなにおける CSS Modules、及び CSS Modules に足りないもの / CSS Modules in Hatena, and CSS Modules missing parts
mizdra
7
970
スクラムガイドのスプリントレトロスペクティブを改めて読みかえしてみた / Re-reading the Sprint Retrospective Section in the Scrum Guide
mackey0225
3
480
if constexpr文はテンプレート世界のラムダ式である
faithandbrave
3
670
Implementing Design Systems in Swift
seyfoyun
1
440
CDKコントリビュートの最初の壁を越えよう! -簡単issueの見つけ方-
badmintoncryer
3
180
Netty Chicago Java User Group 2024-04-17
sullis
0
200
PostmanでAPIの動作確認が楽になった話
h455h1
0
180
Domain-Driven Transformation
hschwentner
2
1.5k
Anthropic Cookbook のおすすめレシピ
schroneko
7
1.1k
Featured
See All Featured
How GitHub Uses GitHub to Build GitHub
holman
468
290k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
51k
The Cost Of JavaScript in 2023
addyosmani
20
3.9k
Into the Great Unknown - MozCon
thekraken
14
1k
What's in a price? How to price your products and services
michaelherold
238
11k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
649
58k
Large-scale JavaScript Application Architecture
addyosmani
504
110k
Making the Leap to Tech Lead
cromwellryan
125
8.5k
Fireside Chat
paigeccino
22
2.6k
Raft: Consensus for Rubyists
vanstee
133
6.3k
StorybookのUI Testing Handbookを読んだ
zakiyama
13
4.6k
Transcript
RUBY 2.0 What u in DOMAS BITVINSKAS domasbitvinskas.com @Nedomas
20 27.days.ago ruby can almost play poke lega y
Syntax sparkle Evolved monkeys PERFORMANCE booooost PR “100 hundred procent
compatibl” - Matz
❤ = 'love' puts ❤ UTF-8 default encoding
class Integer def dalinasi_iš?(skaičius) skaičius != 0 ? self %
skaičius == 0 : zero? end end puts 6.dalinasi_iš?(2)
kwargs
# ruby 1.9 def shout(opts={}) loud = opts[:loud] || 'Hello'
quiet = opts[:quiet] || 'World' p "#{loud} #{quiet}!" end shout loud: "Old", quiet: "School" # ruby 2.0 def shout(loud: 'Hello', quiet: 'World') p "#{loud} #{quiet}!" end shout loud: "New", quiet: "School"
%i(an array of symbols) => [:an, :array, :of, :symbols] %I(#{100-50}
shades of grey) => [:"50", :shades, :of, :grey] PRO-TIP
module Logger def log(msg) p msg end end class Logic
include Logger def log(msg) p msg.reverse end end Module prepend
module Logger def log(msg) p msg end end class Logic
prepend Logger def log(msg) p msg.reverse end end Logic.new.log("Some message") # "Some message" Logic.ancestors # include => [Logic, Logger, Object, Kernel, BasicObject] # prepend => [Logger, Logic, Object, Kernel, BasicObject] Module prepend
ENUMERATORS even_numbers = (1..10000).select(&:even?).map(&:to_s) even_numbers = (1..10000).inject([]) do |acc, number|
if number.even? acc << number.to_s else acc end end for the lazy
ENUMERATORS even_numbers = (1..10000).lazy.select(&:even?).map(&:to_s) even_numbers = (1..10000).inject([]) do |acc, number|
if number.even? acc << number.to_s else acc end end for the lazy
REFINEMENTS experimental module Fun refine Fixnum do def +(_) super
- rand(3) end end end using Fun p 5 + 5
MAŽI GRAŽŪS DALYKAI
Drummer = Struct.new(:name, :age, :band) idol = Drummer.new("Carter Beauford", 55,
"Dave Matthews Band") p idol # => #<struct Drummer name="Carter Beauford", age=55, band="Dave Matthews Band"> p idol.to_h # => {:name=>"Carter Beauford", :age=>55, :band=>"Dave Matthews Band"} .to_h
ONIGMO REGEX VARIKLIS "this\nis\vMr.\rNeo".gsub(/\R/, ' ')
Array Range #bsearch p [1, 2, 3, 6, 9, 15].bsearch
{|i| i > 4 } p (1..10000000000000).bsearch {|i| i > 9 }
_ _di _ _
IMPROVE GARBAGE & STUFF! RubyGem 2.0 & RDoc 4.0
AČIŪ