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 161921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:17:58+00:00 2026-05-11T11:17:58+00:00

In this example, do the nukes get launched because any changes that you make

  • 0

In this example, do the nukes get launched because any changes that you make to buggy_logger get applied to the ‘status’ string – just like using a copy of a reference to an object -> when you make a change to the copy of the reference, the change gets applied to the underlying object -> that change is, in turn, reflected in any other references to the object. So, in other words, buggy_logger is an alias to the ‘status’ object without specifically using the alias keyword? Is that correct? So, in ruby, you just say

b = a 

and then any changes you make to b afterwards are also reflected in a. Or is this only true because we’re talking about Strings, which are mutable in Ruby?

# example-4.rb  status = 'peace'  buggy_logger = status  print 'Status: ' print buggy_logger << '\n' # <- This insertion is the bug.  def launch_nukes?(status)   unless status == 'peace'     return true   else     return false   end  end  print 'Nukes Launched: #{launch_nukes?(status)}\n'  # => Status: peace # => Nukes Launched: true 
  • 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. 2026-05-11T11:17:58+00:00Added an answer on May 11, 2026 at 11:17 am

    Yes, it is because strings are objects. Try

    buggy_logger = status.dup 

    If you want a distinct object with the same initial value.

    As for your question about alias I suspect you aren’t correctly understanding how alias is used in ruby; it’s used on methods, not objects, and isn’t related to mutability.

    Note also that the same semantics would have applied with any class; if status had been an array, a file, or anything else (provided it had mutable state suitable for use as a logger), you would have gotten analogous results.

    One warning about dup though. If your object refers to other objects, the copy will also refer to the same objects. It’s fine once you start thinking about it the right way, but tricky till then.

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

Sidebar

Ask A Question

Stats

  • Questions 101k
  • Answers 101k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Given that you have a lot of data points of… May 11, 2026 at 8:06 pm
  • Editorial Team
    Editorial Team added an answer Try using debug on the results of your form. http://guides.rubyonrails.org/debugging_rails_applications.html#debug May 11, 2026 at 8:06 pm
  • Editorial Team
    Editorial Team added an answer It's simply a way to store user information. A couple… May 11, 2026 at 8:06 pm

Related Questions

I'm trying to figure out the best way to insert a record into a
Let's suppose I'm using the Northwind database and I would like to run a
In Delphi 2007, I added a new string type to my project: type String40
In this example the .Stub returns a new memory stream. The same memory stream

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.