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
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
Other Decks in Programming
See All in Programming
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
420
protojson における文字化けの扱い
kazuki1023
0
240
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
130
仕様駆動開発入門 (何を作るかを先に決めて渡す) | 目指せ Kiro マスター 05
inariku
PRO
2
110
PyConTW 2026 - AI Coding 不只是工具升級, 區域醫院醫療資訊系統協作開發與資訊團隊轉型實踐
cclai999
0
250
Modernizing iOS Apps
seyfoyun
0
150
AI駆動開発4年目の現在地(『あなたはFDEになるべきか?』イベント資料)
kumaiu
0
570
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
240
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
160
LLM 101
dalinaum
0
480
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
3
1.7k
Vapor Mode でアクセシビリティは 壊れないか検証した話
fuqda
1
340
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
1k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
A designer walks into a library…
pauljervisheath
211
25k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
470
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
520
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
300
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.7k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
350
Transcript
! ! 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