I was also wondering how to drop multiples while looping...
d = [7, 6, 5, 4, 3, 2, 1]
d.find_all {|i| i % 3 == 0 }




Posted 12 September 2011 - 02:02 AM
d = [7, 6, 5, 4, 3, 2, 1]
d.find_all {|i| i % 3 == 0 }
Posted 12 September 2011 - 02:55 AM
d.each do |i|
d.delete(i) if i % 3 == 0
end
Posted 12 September 2011 - 07:02 AM
d = d.reject{|num| num % 3 == 0}
d.reject! {|num| num % 3 == 0}
Posted 14 September 2011 - 10:59 PM
jb1drv, on 13 September 2011 - 03:41 AM, said:
2) Open Aptana
File -> New -> Ruby Project
Name: Hello
Radio: "i'll generate my own code"
Button => "Finish"
3) Click on tab, "Project Explorer" (on left)
4) Right click "Hello" (should be an Icon of a folder)
New -> File
File Name: hello.rb
Button => "Finish"
5) Type in your hello world code
# BEGIN ACTUAL CODE
language = "Ruby"
puts "Hello World of Aptana: " + language
# END ACTUAL CODE
6) Click green play button (top bar)
Quote
This post has been edited by NotarySojac: 14 September 2011 - 11:13 PM
Posted 14 September 2011 - 11:41 PM
require 'tk' # does this throw an error? Then figure out how to install tk somehow. Then we'll make windows and stuff!
language = "Ruby"
puts "Hello World of Aptana: " + language
def save_a_baby_in_a_rickety_old_stroller(amnt=0) # now what could this be for?
baby = 0
stroller = 100
baby = baby + amnt
world = stroller / baby
puts world
end
root = TkRoot.new() { title "Hello, world!" } # Title a new window, yes we definately need a root
label = TkLabel.new() { text "" } # Let's add a completely empty, boring label
label.pack("side"=>"left")
label.text = "TO" # Ok, it can say "TO" but this is quite random in my opinion
button = TkButton.new(root) { # hmmm, now let's splash in a button
text "First, rightmost" # and it will have text
command do # and there will be an action!
save_a_baby_in_a_rickety_old_stroller(1)
label.text = "SAVED!"
end
}
# but where shall we place this strange new button? And how long...
button.pack("side"=>"right", "fill"=>"y") # We'll put it to the right, and let it stretch out along it's lovely y axis
Tk.mainloop() # OK, show the window! WOOH-POW!!!
Posted 03 October 2011 - 01:39 PM
NotarySojac, on 15 September 2011 - 12:59 AM, said:
