Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6992999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:42:28+00:00 2026-05-27T19:42:28+00:00

The rules of Ruby’s super keyword is that if it is called without arguments,

  • 0

The rules of Ruby’s super keyword is that if it is called without arguments, all of the original arguments are forwarded. If it is called with explicit arguments, the explicit arguments are exclusively passed in.

In this example, arguments should never be forwarded, since I am calling super with exact arguments.

Example:

@doc = Nokogiri::HTML::DocumentFragment.parse("<body></body>")

class Cat < Nokogiri::XML::Node
  def initialize(arg1, arg2)
    super("cat", arg2) # Pass arg2 to super
    # Do something with arg1 later
  end
end

When calling: Cat.new("dog", @doc) I expect to get back a <cat></cat> tag, and I expect the first argument to be ignored. Instead I am getting a <dog></dog> tag.

Is there a reason this case would defy expected behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:42:29+00:00Added an answer on May 27, 2026 at 7:42 pm

    If you look at the source to nokogiri, it’s actually the new method that sets the node’s name, not the initialize method. Nothing mysterious is happening with regards to invoking super, it’s just that the initialize method doesn’t do anything with those arguments.

    I assume this is because the new method is the one that is supposed to be allocating storage and so on for the object, which in nokogiri’s case means creating the underlying libxml node, which is the thing that contain’s the node’s name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Ruby on Rails, if all of the validation rules for a given model
With at-rules, it's possible to have a ruleset for elements during that at-rule event
So I decided that I was going to give Ruby (first 1.9.1, then 1.8.7)
I want to send messages between Ruby processes via TCP without using ending chars
I'm not very good with ruby so I'm very thankful for all the help
I'm writing an applicaton that is, at its core, a rules engine. The users
I have a Ruby on Rails app that I'm working on and I'm having
I have a set of business rules that I need to enforce, such as:
To index my website, I have a Ruby script that in turn generates a
I am a Ruby beginner. From the book, I know that a Ruby method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.