This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
shoes_tutorial_html / mdowns / 00535_Scope__local_variable_and_instance_variable.mdown
Scope: local variable and instance variable
We need to learn the scope, the difference between local variable and instance variable, over and over again.
# sample60.rb
Shoes.app :width => 300, :height => 300 do
i = 45
button 'new'do
i += 5
box = rand(2) == 0 ? rect(i, i, 20) : oval(i, i, 20)
box.style :fill => send(COLORS.keys.map{|sym|sym.to_s}[rand(COLORS.keys.size)])
@flag = false
box.click{@flag = true; @box = box}
box.release{@flag = false}
motion{|left, top| @box.move(left-10, top-10) if @flag}
end
end
sample60.png

This snapshot is created by the following setps. - clicked 'new' button 30 times - picked up and drew 6 ovals to the lower side - picked up and drew 7 rects to the upper side
Policeman
The sample60.rb worked well with Shoes-0.r1263







