def self.grab
article = self.article_names
links = self.article_links
body = self.article_body
articles = {}
articles[:title] = article
articles[:url] = links
articles[:body] = body
art = Ello::Hello.new
art(articles)
end
When I run this with
class Ello::Hello
attr_accessor :url, :article, :body,
@@all = []
def initialize(hash)
@article = hash["title"]
@body = hash["body"]
@url = hash["url"]
@@all << self
end
def self.all
@@all
end
end
I get wrong number of arguments error? I know that usually when it says wrong number it means that it's not exactly reading the argument that I put in. But I feel like I did put in an argument but I'm unsure of why it's not being read.
In such cases, you should always paste the complete error message, and indicate which line in your code is affected.
Anyway, I can see that your wrote art = Ello::Hello.new
(0 arguments), but the initialize
method for this class expects 1 argument.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.