Skip to content

Instantly share code, notes, and snippets.

@FlatMapIO
Created November 11, 2014 10:59
Show Gist options
  • Save FlatMapIO/12a63dab4e71a2eeffbc to your computer and use it in GitHub Desktop.
Save FlatMapIO/12a63dab4e71a2eeffbc to your computer and use it in GitHub Desktop.
string extends ipable
(defprotocol IPify
(as-ip-array [this] "Take a string convert to InetAddress[]")
(as-ip [this] "Take a string convert to InetAddress[] only returh first item"))
(extend-type String
IPify
(as-ip-array [this]
(InetAddress/getAllByName this))
(as-ip [this]
(first (as-ip-array this))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment