Hi

I have my initialise constructor, why won't my function to_hash work ?

def initialize(msg)
    @original_msg = msg.strip.delete(' ')
    s = ["|","^"]
    @chunked_msg = @original_msg.split(s[0])
    @msg_hash.self.to_hash
end

def to_hash
    @chunked_msg.each do |x|
      s =  x.split("=")
      @msg_hash[s[0]] = s[1]
    end
    return @msg_hash
end

Solved it, just needed to write self.to_hash

def initialize(msg)
    @original_msg = msg.strip.delete(' ')
    s = ["|","^"]
    @chunked_msg = @original_msg.split(s[0])
    self.to_hash
end

def to_hash
    @chunked_msg.each do |x|
      s =  x.split("=")
      @msg_hash[s[0]] = s[1]
    end
    return @msg_hash
end
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.