Hi,
--- On Sun, Jul 19, 2009 at 12:11 AM, chandana
boral<[email protected]> wrote:
| I have pasted it in this link http://fpaste.org/paste/18773 .
| I am having this error
| < cor.rb:12:in `av': undefined method `/' for "78":String (NoMethodError)
| from cor.rb:15>
\--
1. The input that you get from 'gets' is a 'string'. You can't do '/'
on strings. You need to convert the string to an integer using to_i(),
like this:
p = (ma1.to_i() + ma2.to_i()) / 2
2. Use 'shebang' notation when you start a Ruby script:
#!/usr/local/bin/ruby -w
-w is for verbose mode.
3. You don't need to explicitly specify '()' for a function in Ruby.
Its syntax is to keep things simple and readable.
4. You don't need to 'return' explicitly in a Ruby function. The
result of the last statement in a Ruby function is returned
automatically.
5. Give a space on either side of an operator like '='. Helps in readability.
SK
--
Shakthi Kannan
http://www.shakthimaan.com
_______________________________________________
Users mailing list
[email protected]
http://lists.dgplug.org/listinfo.cgi/users-dgplug.org