--001485f2d0d6789654048ef1e6a3
Content-Type: text/plain; charset=ISO-8859-1

On Sat, Aug 28, 2010 at 11:17 AM, Cameron Vessey <cameron1inm / hotmail.com>wrote:

> Why does this return nil for @city?
>
> class Url
>  def initialize(city,quary,catagory,minask,maxask)
>    @city  ity
>    @quary  uary
>    @cat  atagory
>    @min  inask
>    @max  axask
>  end
>
>  puts @city
>
> end
> a  rl.new('spokane',"tires","pts","0","1000")
> a
> --
> Posted via http://www.ruby-forum.com/.
>
>

This is basically what Jean said, but I figured it might be easier to follow
if you can actually see it.

class Url
  # self is the class Url
  puts "outside initialize 1, self is #{self.inspect}"

  def initialize(city,quary,catagory,minask,maxask)
    @city  ity
    @quary  uary
    @cat  atagory
    @min  inask
    @max  axask
    # self is an instance of Url
    puts "Inside initialize 3, self is #{self.inspect}"
  end

  # self is the class Url
  puts "outside initialize 2, self is #{self.inspect}"

  def render
    # self is an instance of Url
    puts "Inside initialize 4, self is #{self.inspect}"
    @city + @quary + @cat + @min + @max
  end
end


a  rl.new('spokane',"tires","pts","0","1000")
result  .render
puts "result is #{result.inspect}"

--001485f2d0d6789654048ef1e6a3--