After studying the ruby ββfor a month, I decided to move to Sinatra. I need help understanding an Sinatra fragment that illustrates conditions and routing. Can someone clearly explain what happens in turn, and how does this block actually randomize the route?
set(:probability) { |value| condition { rand <= value } }
get '/win_a_car', :probability => 0.1 do
"You won!"
end
get '/win_a_car' do
"Sorry, you lost."
end
source
share