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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:04:17+00:00 2026-06-16T01:04:17+00:00

I have: @property float x(float[2] vector) { return vector[0]; } @property void x(float[2] vector,

  • 0

I have:

@property float x(float[2] vector)
{
    return vector[0];
}

@property void x(float[2] vector, float value)
{
    vector[0] = value;
}

I can declare an array, for example float[2] a; and later get the first element of the array by simply calling a.x, but if I want to set a[0], I can’t call a.x = 3.14. It does not cause problems to the compiler nor throws an exception. And later when I get a[0] it says it is NaN which is float.init. This means that a[0] was never set and a.x is valid and invalid at the same time.

I simply want a float array and have a get and set property x. Is there a way to do that?
And I know that I can use a.x(3.14) for setting a[0], but I want to make it as if x is a member property of a.

  • 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-06-16T01:04:19+00:00Added an answer on June 16, 2026 at 1:04 am

    Static arrays are passed by value. You need to use ref to pass by reference:

    @property float x(ref float[2] vector)
    @property void x(ref float[2] vector, float value)
    

    Note: I’m referring to D2. AFAIK in D1 static arrays used to be passed by reference, but in D2 they’re passed by value by default.

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

Sidebar

Related Questions

I have a div with float:right (no position property declared). This div has some
hi i have property named. public bool ShowLabels{get; set;} and one toolbar menu button
I have a property float a and I want to interpolate between two values,
I'm experimenting with CSS and the float property. I have this website, with a
I have decimal (18,2) data in sql and I set float the property of
I have a vector class with a properly overloaded Vect*float operator and am trying
I have things object called - bombObject, which has a float property called 'blastRadius'.
I have a bunch of images each with the float: left property applied to
I have a 2-by-2 grid of images arranged using float property in CSS. I
When you need to have very small objects, say that contains 2 float property,

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.