pack and unpack in ruby

- 1 min

I still enjoy how complex operations become simple when using ruby:

module Converter
  def self.to_ascii(hex)
    return [hex].pack("H*")
  end

  def self.to_hex(ascii)
    return ascii.unpack('H*')[0]
  end
end
Carles Hernandez-Ferrer

Carles Hernandez-Ferrer

Bioinformatics, data analysis and software development

rss facebook twitter github gitlab youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora