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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:14:09+00:00 2026-05-24T04:14:09+00:00

I have code: def make_all_thumbs(source) sizes = [‘1000′,’1100′,’1200′,’800′,’600’] threads = [] sizes.each do |s|

  • 0

I have code:

  def make_all_thumbs(source)
    sizes = ['1000','1100','1200','800','600']
    threads = []
    sizes.each do |s|
      threads << Thread.new(s) {
        create_thumbnail(source+'.png', source+'-'+s+'.png', s)
      }
    end
  end

what does << mean?

  • 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-24T04:14:10+00:00Added an answer on May 24, 2026 at 4:14 am

    It can have 3 distinct meanings:

    ‘<<‘ as an ordinary method

    In most cases ‘<<‘ is a method defined like the rest of them, in your case it means "add to the end of this array" (see also here).

    That’s in your particular case, but there are also a lot of other occasions where you’ll encounter the "<<" method. I won’t call it ‘operator’ since it’s really a method that is defined on some object that can be overridden by you or implemented for your own objects. Other cases of ‘<<‘

    • String concatenation: "a" << "b"
    • Writing output to an IO: io << "A line of text\n"
    • Writing data to a message digest, HMAC or cipher: sha << "Text to be hashed"
    • left-shifting of an OpenSSL::BN: bn << 2
    • …

    Singleton class definition

    Then there is the mysterious shift of the current scope (=change of self) within the program flow:

    class A
      class << self
        puts self # self is the singleton class of A
      end
    end
    
    a = A.new
    class << a
      puts self # now it's the singleton class of object a
    end
    

    The mystery class << self made me wonder and investigate about the internals there. Whereas in all the examples I mentioned << is really a method defined in a class, i.e.

    obj << stuff
    

    is equivalent to

    obj.<<(stuff)
    

    the class << self (or any object in place of self) construct is truly different. It is really a builtin feature of the language itself, in CRuby it’s defined in parse.y as

    k_class tLSHFT expr
    

    k_class is the ‘class’ keyword, where tLSHFT is a ‘<<‘ token and expr is an arbitrary expression. That is, you can actually write

    class << <any expression>
    

    and will get shifted into the singleton class of the result of the expression. The tLSHFT sequence will be parsed as a ‘NODE_SCLASS’ expression, which is called a Singleton Class definition (cf. node.c)

    case NODE_SCLASS:
        ANN("singleton class definition");
        ANN("format: class << [nd_recv]; [nd_body]; end");
        ANN("example: class << obj; ..; end");
        F_NODE(nd_recv, "receiver");
        LAST_NODE;
        F_NODE(nd_body, "singleton class definition");
        break; 
    

    Here Documents

    Here Documents use ‘<<‘ in a way that is again totally different. You can define a string that spans over multiple lines conveniently by declaring

    here_doc = <<_EOS_
    The quick brown fox jumps over the lazy dog.
    ...
    _EOS_
    

    To distinguish the ‘here doc operator’ an arbitrary String delimiter has to immediately follow the ‘<<‘. Everything inbetween that initial delimiter and the second occurrence of that same delimiter will be part of the final string. It is also possible to use ‘<<-‘, the difference is that using the latter will ignore any leading or trailing whitespace.

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

Sidebar

Related Questions

I have this code: def setVelocity (x, y, yaw) setVelocity (Command2d.new(x,y,yaw)) end def setVelocity
I have code: class Scene def initialize(number) @number = number end attr_reader :number end
i have the following code def get(self): date = datetime.date.today() loc_query = Location.all() last_cursor
I have code like this (simplified): def outer(): ctr = 0 def inner(): ctr
Let's say I have the following ruby code : def use_object(object) puts object.some_method end
I have the following code: class IncidentTag: def __init__(self,tag): self.tag = tag def equals(self,obj):
So I have this code inside my lib/ folder: class GlobalConfig::SetHelper def self.yes_no_input(configuration) value
If I have a block of code like this: def show @post = Post.find(params[:id])
If I have the following piece of Ruby code: class Blah def self.bleh @blih
I have the following code: #!/usr/bin/ruby class Person def self.speak p = self.new puts

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.