Function Parameters Solutions - D Programming Language

Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Downloads
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Calendar
  - Discord (community-run)
  - Forums
  - IRC
  - Wiki
  - Issues
  - Contributing
  - Contributors
  - Foundation
  - Security Team
  - Donate
  - Sponsors
- Resources
  - Tour
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - run.dlang.io
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

# Function Parameters Solutions

#### Function Parameters Dersi Problem Çözümleri

Because the parameters of this function are the kind that gets copied from the arguments, what gets swapped in the function are those copies.

To make the function swap the arguments, both of the parameters must be passed by reference:

    void swap(ref int first, ref int second) {
        const int temp = first;
        first = second;
        second = temp;
    }

With that change, now the variables in `main()` would be swapped:

    2 1

Although not related to the original problem, also note that `temp` is specified as `const` as it is not changed in the function.

Copyright © 1999-2026 by the D Language Foundation | Page generated by Ddoc on Wed Aug 5 11:24:17 2026