Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Learning Ruby

  1. Apr 15, 2008 #1
    I'm learning how to program with Ruby and would like some brains to pick.

    Here's the context:

    class Run_Record
    def initialize
    @run_number=gets
    @time=gets
    ##in the future this will be more complicated
    end
    def property(arg)
    #????
    end
    end

    new_run=Run_Record.new
    p new_run.property(:run_number)

    What do I write in #???? to get the last line to print the run number it gets from the initiation? It seems like there should be a simple way to do this, something that would work kind of like #{arg} inside of strings. I realize that I can accomplish the ultimate task by using the attr_reader method, but I'm curious about whether one could approach the problem this way.
     
    Last edited: Apr 15, 2008
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you help with the solution or looking for help too?
Draft saved Draft deleted



Similar Discussions: Learning Ruby
  1. 1D simulator (Ruby) (Replies: 0)

Loading...