P
P
piece of internet2018-10-21 18:51:02
ruby
piece of internet, 2018-10-21 18:51:02

How to limit the size of one hash entry in Ruby?

Suppose I need one entry (key => value) to have a fixed size of 200 bytes.
When creating a record with a size larger, I display an error in the console.
How can I do this using the language?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AVKor, 2018-10-21
@AVKor

#!/usr/bin/env ruby

str = 'йцукен'
puts 'Error' if str.bytesize > 10

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question