Saturday, August 4, 2007

how to play ruby language with Letters


how to play ruby language with Letters
We reffer to groups of letters in a programs as strings. (you can think of beads with letters on them being strung together.) to make it easier to see just what part of the code is in a string, I'll color strings 'blue'
show this image for result


here is some string

'hi all'
'Anand Kumar Pathak'
'11 is my favorite number...and yours favorite number?'
'hey !@#$%^&*() heeeeeeeeee wowwwwwwww'
''
as you can see, strings can have punctation, digits, symbols, and spacesin them.. more than just letters. That last string doesn't have anything in it at all; we call that an empty string.
program
puts 'hi all'
puts 'Anand Kumar Pathak'
puts '11 is my favorite number...and yours favorite number?'
puts 'hey !@#$%^&*() heeeeeeeeee wowwwwwwww'
puts ''
puts 6.0 / 2.0
puts 3 * 2
puts 3 - 7
puts 7 / 2
puts 5 * (12 - 8) + -15
puts 98 + (489572 / (9 * 12)) * -15
program result
>ruby 1.rb
hi all
Anand Kumar Pathak
11 is my favorite number...and yours favorite number?
hey !@#$%^&*() heeeeeeeeee wowwwwwwww

3.0
6
-4
3
5
-67897
>Exit code: 0

No comments: