#rubystrings — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #rubystrings, aggregated by home.social.
-
We are kind of used to this, but still it is somhow illogical: A Range object, which represents *empty*, can still have an effect when used as a string index:
range = 0..-3
range.to_a.empty? #=> true
"Ruby"[range] #=> "Ru"It feels less "wrong" when using Ruby's more recent beginless ranges:
"Ruby"[..-3] #=> "Ru"
-
We are kind of used to this, but still it is somhow illogical: A Range object, which represents *empty*, can still have an effect when used as a string index:
range = 0..-3
range.to_a.empty? #=> true
"Ruby"[range] #=> "Ru"It feels less "wrong" when using Ruby's more recent beginless ranges:
"Ruby"[..-3] #=> "Ru"
-
We are kind of used to this, but still it is somhow illogical: A Range object, which represents *empty*, can still have an effect when used as a string index:
range = 0..-3
range.to_a.empty? #=> true
"Ruby"[range] #=> "Ru"It feels less "wrong" when using Ruby's more recent beginless ranges:
"Ruby"[..-3] #=> "Ru"
-
We are kind of used to this, but still it is somhow illogical: A Range object, which represents *empty*, can still have an effect when used as a string index:
range = 0..-3
range.to_a.empty? #=> true
"Ruby"[range] #=> "Ru"It feels less "wrong" when using Ruby's more recent beginless ranges:
"Ruby"[..-3] #=> "Ru"
-
We are kind of used to this, but still it is somhow illogical: A Range object, which represents *empty*, can still have an effect when used as a string index:
range = 0..-3
range.to_a.empty? #=> true
"Ruby"[range] #=> "Ru"It feels less "wrong" when using Ruby's more recent beginless ranges:
"Ruby"[..-3] #=> "Ru"