Skip to content

Files

Latest commit

4c15a54 · Sep 28, 2019

History

History
23 lines (16 loc) · 242 Bytes

replace-primitive-with-object.md

File metadata and controls

23 lines (16 loc) · 242 Bytes

Replace Primitive With Object

Example

Before

def protocol(url_string)
  url_string.match(/^([^:]+):/)[1]
end

After

def protocol(url)
  url.scheme
end

# ... elsewhere ...

url = URI.parse(url_string)