Ruby - Enumerable - collect

  • + 0 comments
    def rot13(secret_messages)
      secret_messages.map do |string|
        string.chars.map { |c| c.ord < 97 || c.ord > 122 ? c : c.ord + 13 > 122 ? (c.ord - 13).chr : (c.ord + 13).chr }.join
      end
    end