Sha256: df14a697df3becbe0a3aebcde93a55ce1469b73ed76c1c62694f035b2b2f5ddb

Contents?: true

Size: 864 Bytes

Versions: 4

Compression:

Stored size: 864 Bytes

Contents

require 'ruby-processing'

# Ruby has dynamic typing, so you don't have to say
# what kind of thing a variable is before using it.
class VariableDeclaration < Processing::App

  def setup
    count = 0         # count gets assigned 0, an integer (Fixnum)
    letter = 'a'      # letter gets the letter 'a', a String
    d = 132.32        # d gets the decimal 132.32, a Float (floating-point number)
    happy = false     # happy gets false, a Boolean (true or false)
    x = 4.0           # x gets 4.0, another Float
    y = nil           # y gets nil, which stands for nothing
    y = x + 5.2       # assign the value of x plus 5.2 to y
    z = x * y + 15.0  # z gets the value of x times y plus 15.0 (or 51.8)
  end
  
  def draw
  
  end
  
end

VariableDeclaration.new :title => "Variable Declaration and Initialization Examples", :width => 200, :height => 200

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-processing-1.0.1 samples/learning_processing/chapter_04/1_variable_declaration.rb
ruby-processing-1.0.2 samples/learning_processing/chapter_04/1_variable_declaration.rb
ruby-processing-1.0.4 samples/learning_processing/chapter_04/1_variable_declaration.rb
ruby-processing-1.0.3 samples/learning_processing/chapter_04/1_variable_declaration.rb