1. Spend some time moving your way through the 46 Ruby coding examples in the Ruby Tutorial with Code from http://www.fincher.org/tips/Languages/Ruby/
Done
2. What are the syntax differences in the way that Ruby and Javascript use the if statement?
Using if statement, javascript has the ability to make distinctions between different possibilities. For example, you might have a script that checks if Boolean value is true or false, if variable contains number or string value, if an object is empty or populated, or even check type and version of the visitors browser (“JavaScript If statement” n.d.).
An if statement in Ruby is pretty similar to “if” statements in other languages. If you lay out your if statements on multiple lines, you can leave off the then keyword. However, if you lay your code out more tightly, the then keyword is necessary to separate the Boolean expression. May have zero or more elsif clauses and an optional else clause.
3.While Ruby and Python are quite similar, can you find some similarities between Ruby and Javascript?
JavaScript has many of the same language features Ruby has, includingextension by mixin, duck typing, a YAML equivalent (JSON), arbitrary classand object extension (i.e. adding methods/properties to classes or specificobjects at any time), simple arrays and hashes, etc.
It also hasfirst-class functions, which are equivalent (though not identical) toblock (FAQ and JavaScript vs. Ruby, n.d.)
Reference
ASP Net Center, Retrieved March 31,2009, from ://www.aspnetcenter.com/cliktoprogram/javascript/ifstatement.asp
FAQ and JavaScript vs. Ruby (was Re: rubynuby - client side Ruby?), Retrieved March 30, 2009, from http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.ruby/2006-02/msg02949.html
Programming Ruby The Pragmatic Programmer’s Guide, Retrieved March 31,2009, from http://www.rubycentral.com/pickaxe/tut_expressions.html
No comments:
Post a Comment