K
Size: a a a
K
Ф
SR
Ф
С
С
K
cuurjol@cuurjol-GL65-9SDK:~/ror/work/jjo/jjo-invest-backend$ bundle exec rails console
RUBY_VERSIORunning via Spring preloader in process 10237
NLoading development environment (Rails 6.1.4)
[1] pry(main)> RUBY_VERSION
=> "2.7.3"
[2] pry(main)> ..13
Error: there was a problem executing system command: .13
[3] pry(main)> ..15
Error: there was a problem executing system command: .15
[4] pry(main)> .15
Error: there was a problem executing system command: 15
[5] pry(main)> (..13).to_a
RangeError: cannot get the first element of beginless range
from /home/cuurjol/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4/lib/active_support/core_ext/range/each.rb:19:in `first'
[6] pry(main)>
K
Ф
localhost :: ~ » irb
irb(main):001:0> RUBY_VERSION
=> "2.7.1"
irb(main):003:0> ..15
=> ..15
С
K
cuurjol@cuurjol-GL65-9SDK:~/ror/my_projects/alarm_clock$ irb
irb(main):001:0> RUBY_VERSION
=> "2.7.3"
irb(main):002:0> ..15
=> ..15
irb(main):003:0> (..15).to_a
Traceback (most recent call last):
7: from /home/cuurjol/.rbenv/versions/2.7.3/bin/irb:23:in `<main>'
6: from /home/cuurjol/.rbenv/versions/2.7.3/bin/irb:23:in `load'
5: from /home/cuurjol/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
4: from (irb):3
3: from (irb):3:in `to_a'
2: from (irb):3:in `to_a'
1: from (irb):3:in `each'
TypeError (can't iterate from NilClass)
irb(main):004:0>
Ф
K
Ф
Ф
irb(main):017:0> b = 123
=> 123
irb(main):018:1* def a(b:)
irb(main):019:1* b
irb(main):020:0> end
=> :a
irb(main):021:0> a(b:)
=> 123
K
Ф
Э
ary[1:]
Аналогично в Рубиary[1..]
Выглядит более человекочитаемым, чем до этого ary[1..-1]
PK
С