Skip to content

Commit

Permalink
first commit, Ruby learning
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Wang committed Apr 6, 2012
0 parents commit 573ec03
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .loadpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<loadpath>
<pathentry path="" type="src"/>
<pathentry path="org.rubypeople.rdt.launching.RUBY_CONTAINER" type="con"/>
</loadpath>
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>FirstRuby</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.rubypeople.rdt.core.rubybuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.rubypeople.rdt.core.rubynature</nature>
</natures>
</projectDescription>
32 changes: 32 additions & 0 deletions src/Array.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
3.times { print "Ruby!"}
1.upto(9) { |x| print x}

a =[1,2,3]
a.each do |elt|
print "\n"
print elt
end

b = [1,2,3,4]

c = b.map { |e| e*e }

print "\n"
c.each do |e|
print e
print " "
end
print "\n"

d = c.select {|x| x > 10}
d.each do |e|
print e
print " "
end
print "\n"

print "array inject demo"
sum = 0
sum = a.inject {|sum, x| sum + x}

print sum

0 comments on commit 573ec03

Please sign in to comment.