АО
Вроде строки есть, но пользоваться ими нельзя, если нужно, чтобы они работали быстро.
Size: a a a
АО
АО
АО
RS
nextind написано, а как только я сконвертировал в полный размер, то скорость выросла в 2-3 раза сразу.RS
nextindRS
АО
str = "abываcdf"
@btime collect(eachindex($str)) # 72.807 ns (2 allocations: 160 bytes)
@btime collect($str) # 52.985 ns (1 allocation: 112 bytes)
АО
str = "abываcdf"
str2 = collect("abываcdf")
@btime $str[9] # 2.389 ns (0 allocations: 0 bytes)
@btime $str2[6] # 1.339 ns (0 allocations: 0 bytes)
АО
АО
RS
str = "abываcdf"
str2 = collect("abываcdf")
@btime $str[9] # 2.389 ns (0 allocations: 0 bytes)
@btime $str2[6] # 1.339 ns (0 allocations: 0 bytes)
АО
RS
KT
АО
АО
АО
АО
АО
RS
RSpec.describe Game do
describe "#score" do
it "returns 0 for an all gutter game" do
game = Game.new
20.times { game.roll(0) }
expect(game.score).to eq(0)
end
end
end