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

  • Home
  • SEARCH
  • 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 733833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:18:07+00:00 2026-05-14T07:18:07+00:00

When I type this: puts ‘repeat’ * 3 I get: >> repeat repeat repeat

  • 0

When I type this:

puts 'repeat' * 3

I get:

>> repeat repeat repeat

But it’s not working if I do this:

puts 3 * 'repeat'

Why?

  • 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-14T07:18:08+00:00Added an answer on May 14, 2026 at 7:18 am

    In Ruby, when you call a * b, you’re actually calling a method called * on a. Try this, for example:

    a = 5
    => 5
    b = 6
    => 6
    a.*(b)
    => 30
    
    c = "hello"
    => "hello"
    c.*(a)
    => "hellohellohellohellohello"
    

    Thus <String> * <Fixnum> works fine, because the * method on String understands how to handle integers. It responds by concatenating a number of copies of itself together.

    But when you do 3 * "repeat", it’s invoking * on Fixnum with a String argument. That doesn’t work, because Fixnum‘s * method expects to see another numeric type.

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

Sidebar

Ask A Question

Stats

  • Questions 491k
  • Answers 491k
  • 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 See the example in this Apple Discussions thread: Tab Controllers? May 16, 2026 at 10:11 am
  • Editorial Team
    Editorial Team added an answer This is what worked for me using JSF1.2 and facelets:… May 16, 2026 at 10:11 am
  • Editorial Team
    Editorial Team added an answer Yes. Check out deviantART's new drawing tool Muro for an… May 16, 2026 at 10:11 am

Trending Tags

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

Top Members

Related Questions

I have a jQuery selector with following syntax: $('input[type=image]').not('.xyzClass').click(function{ //some functionality }); So this
In Javascript what is this type? a = {x :1 , y: 2}; In
I'm getting an Illegal offset type for this array: public static $CATS_AND_TYPES = array(
I have a question, but let me first say that this is being performed
I'm trying to build an object that looks something like this: public class MyObject
This is an annoyance I've had for a long time. (Nitpicky section: I prefer
s = Proc.new {|x|x*2} puts s.call(5) -> 10 def foo(&a) a.call(5) end puts test
I'm working on an application which interacts with hundreds of devices across a network.
I am sorry if my question does not make any sense. So here is
I am trying to register a generic type in a config file for Unity

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.