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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:01:31+00:00 2026-05-29T11:01:31+00:00

in the :constructors map and subsequent -init definitions, how do I represent a varargs

  • 0

in the :constructors map and subsequent -init definitions, how do I represent a varargs constructor (assuming the superclass has multiple constructors of which one is varargs) ?

  • 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-29T11:01:32+00:00Added an answer on May 29, 2026 at 11:01 am

    Since varargs are essentially syntax sugar for Object arrays, you could just use “[Ljava.lang.Object;” as the type of constructor’s parameter.

    Here’s some sample code:

    (ns t.vtest
      (:gen-class
       :implements   [clojure.lang.IDeref]
       :init init
       :state state
       :constructors {["[Ljava.lang.Object;"] []}))
       ;;                                      ^-----------------------
       ;; You should put "[Ljava.lang.Object;" for superclass varargs constructor here
       ;; I left it blank for the sake of working example 
    
    (defn -init
      [args]
      (println "first element of args" (aget args 0) "total elements" (alength args))
      [[] (into [] args)])
    
    (defn -deref
      [this]
      (.state this))
    

    and that’s how it looks in REPL

    user=> @(t.vtest. (into-array Object ["A" "B" 1 2]))
    first element of args A total elements 4
    ["A" "B" 1 2]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know Grails has a map based constructor for domain objects, to which you
In the constructor of my class, I map the current object ( this ),
In base class constructors I always see a parameterless constructor, like so: public abstract
I have a Person object with two constructors - one takes an int (personId),
When using the std::map with types that use trivial, non-throwing, copy constructors, a compiler
I have a main function in A.cpp which has the following relevant two lines
I am dealing with a set of message objects, each of which has a
I have created N classes that take from one to N ints into constructors
I used to have a normal member variable, which was initialized in the constructors
Does NewExpression.Members inform the LINQ runtime how to map a type's constructor parameters to

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.