Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Funky Ruby 🎉
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Caius
August 02, 2018
Programming
72
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Funky Ruby 🎉
Things you _can_ do in ruby, but _probably_ shouldn't let through code review
Caius
August 02, 2018
Transcript
27 slides
! ! Funky Ruby Things you can do in ruby,
but probably shouldn't let through code review
_why the lucky stiff Try Ruby Why's (poignant) guide to
Ruby (foxes!) Camping (microframework! < 4kb) Hpricot
Why Day 19th August Keep it fun, keep it weird
Key " - Useful, okay # - Sometimes useful, usually
okay $ - Err, wtf㾗
" " String interpolation place = "plant" "We are in
#{place}" # => "We are in plant"
# # String interpolation @place = "plant" "We are in
#@place" # => "We are in plant"
# # String interpolation @pl = "pl" @ant = "ant"
"We are in #@pl#@ant" # => "We are in plant"
$ $ String interpolation @p = "p" @l = "l"
@a = "a" @n = "n" @t = "t" "We are in #@p#@l#@a#@n#@t" # => "We are in plant"
$ $ String interpolation %w(p l a n t).map {
|c| instance_variable_set("@#{c}", c) } "We are in #@p#@l#@a#@n#@t" # => "We are in plant"
$ $ String interpolation %w(e h r).map { |c| instance_variable_set("@#{c}",
c) } "We are #{"#@h#{"#{"#@e#{"#{"#@r#{"#{"#@e"}"}"}"}"}"}"}" # => "We are here"
" " String#% data = {name: "fred"} "I am %{name}"
% data # => "I am fred"
# # Kernel#method (3..5).map { |n| n + 10 }
# => [13, 14, 15] 10.method(:+) # => #<Method: Integer#+> (3..5).map(&10.method(:+)) # => [13, 14, 15]
" " Kernel#method Fence = Struct.new(:items) do def call items.map(&method(:fence_item))
end def fence_item(item) item.inspect end end
" " DATA require "yaml" YAML.load(DATA) # => ["Apples", "Crowbar",
"Sink Plunger"] __END__ # Shopping List - Apples - Crowbar - Sink Plunger
" " DATA DATA.rewind print DATA.read __END__ something goes here
" " UTF-8 Ruby def "Hi FreeAgent" end
# => "Hi FreeAgent"
" " UTF-8 Ruby : % # => : %
# # UTF-8 Ruby
$ $ UTF-8 Ruby class % end # => #
~> -:1: class/module name must be CONSTANT # ~> class % # ~> ^
$ $ UTF-8 Ruby % = Class.new # => #<Class:0x00007007>
% .new # => #<#<Class:0x00007007>:0x00007fe3>
$ $ UTF-8 Ruby & = Struct.new(: ' , :
( ) & .new("Caius", "00770090000") # => #<struct ' ="Caius", ="00770090000">
$ $ Glitch text
" " default method args def greet(name = :default) return
"Hello anon" if name == :default "Hello #{name}" end greet # => "Hello anon" greet "#nwrug" # => "Hello #nwrug" greet :default # => "Hello anon"
$ $ default method args def greet(name = (default =
true; :default)) if default "HAI" elsif name == :default "No. ) " else " * #{name}" end end
$ $ default method args greet # => "HAI" greet
"FreeAgent" # => "Hello FreeAgent" greet :default # => "No. "
Fin.
None
Other Decks in Programming
See All in Programming
RaspberryPi 5で軽くはじめるk3sとtailscaleを用いたホームサーバー構築 (1)
nasum
0
450
Getting Started with Vibe Coding
miccheng
0
250
Datadog を OTel にするメリットを考察する — Datadog との併用を実アプリで確かめる / Examining the Benefits of Moving Datadog to OTel — Testing OTel Alongside Datadog in a Real App
seike460
PRO
1
100
はじめてのKubernetesコントリビューション
nasa9084
0
330
LLM 101
dalinaum
0
550
自宅サーバはどこまで再現できるのか - Proxmox VE上のVM環境をIaCとバックアップで戻してみた
youto
0
450
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
850
Compiling Your Language to WasmGC & Friends
tanishiking
0
630
Math.sumPreciseから学ぶ、ECMAScript仕様の数値の種類
syumai
0
850
作れるエンジニアから、価値を届けるエンジニアへ
ryunakayama
1
1.3k
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
200
特急いなほ as a Workflow / 20261107jaws-festa-2026-akita-lt
kasacchiful
PRO
0
110
Featured
See All Featured
Prompt Engineering for Job Search
mfonobong
0
610
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Unsuck your backbone
ammeep
672
58k
Building Applications with DynamoDB
mza
96
7.3k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
340
Rails Girls Zürich Keynote
gr2m
96
14k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
The Spectacular Lies of Maps
axbom
PRO
1
1.2k
Become a Pro
speakerdeck
PRO
31
6.4k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.8k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.3k