Title: Feature Request: `+` operator should join non-string types if `.toString()` method exists · Issue #2991 · AssemblyScript/assemblyscript · GitHub
Open Graph Title: Feature Request: `+` operator should join non-string types if `.toString()` method exists · Issue #2991 · AssemblyScript/assemblyscript
X Title: Feature Request: `+` operator should join non-string types if `.toString()` method exists · Issue #2991 · AssemblyScript/assemblyscript
Description: Feature suggestion I find it frustrating that both the left and right sides of a String.concat/+ operator cannot join, for example, string and i32. In JavaScript, it Checks to see if the right side of the binary expression is a string If...
Open Graph Description: Feature suggestion I find it frustrating that both the left and right sides of a String.concat/+ operator cannot join, for example, string and i32. In JavaScript, it Checks to see if the right side...
X Description: Feature suggestion I find it frustrating that both the left and right sides of a String.concat/+ operator cannot join, for example, string and i32. In JavaScript, it Checks to see if the right side...
Opengraph URL: https://github.com/AssemblyScript/assemblyscript/issues/2991
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature Request: `+` operator should join non-string types if `.toString()` method exists","articleBody":"### Feature suggestion\n\nI find it frustrating that both the left *and* right sides of a `String.concat`/`+` operator cannot join, for example, `string` and `i32`.\nIn JavaScript, it\n1. Checks to see if the right side of the binary expression is a `string`\n2. If not, it then checks if the right side has a `.toString(): string` method\n3. If so, it calls it and concatenates `left` `+` `right.toString()`\n\nWould be quite simple to implement. For example, this would probably work:\n```ts\nexport class String {\n ...\n @operator(\"+\")\n _concat\u003cT>(left: string, right: T): string {\n if (!isDefined(right.toString())) ERROR(...);\n return this.concat(left, right.toString());\n }\n}\n```","author":{"url":"https://github.com/JairusSW","@type":"Person","name":"JairusSW"},"datePublished":"2026-03-15T21:20:20Z","url":"https://github.com/AssemblyScript/assemblyscript/issues/2991"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cb87bf29-d61b-4614-6ef8-3046731893d5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8308:3A13A0:2A8CD95:39E9392:6B0051C2 |
| html-safe-nonce | 7276dade14d9cce230f71ea44a969a2053b43d6e6cb0e9d6935f448dae55af85 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzA4OjNBMTNBMDoyQThDRDk1OjM5RTkzOTI6NkIwMDUxQzIiLCJ2aXNpdG9yX2lkIjoiNDQ3NzgwNzk0NjgyNjI3MzIxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f19b52112513878c4108b4917e0f691e7921c7075bb69a924bf204023a84838b |
| hovercard-subject-tag | issue:4079218779 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/AssemblyScript/assemblyscript/2991/issue_layout |
| twitter:image | https://opengraph.githubassets.com/da76992898688316e71e61a20075f6887d61ffa25299d47642e02d3cb43a854e/AssemblyScript/assemblyscript/issues/2991 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/da76992898688316e71e61a20075f6887d61ffa25299d47642e02d3cb43a854e/AssemblyScript/assemblyscript/issues/2991 |
| og:image:alt | Feature suggestion I find it frustrating that both the left and right sides of a String.concat/+ operator cannot join, for example, string and i32. In JavaScript, it Checks to see if the right side... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JairusSW |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| turbo-cache-control | no-preview |
| go-import | github.com/AssemblyScript/assemblyscript git https://github.com/AssemblyScript/assemblyscript.git |
| octolytics-dimension-user_id | 28916798 |
| octolytics-dimension-user_login | AssemblyScript |
| octolytics-dimension-repository_id | 105138356 |
| octolytics-dimension-repository_nwo | AssemblyScript/assemblyscript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 105138356 |
| octolytics-dimension-repository_network_root_nwo | AssemblyScript/assemblyscript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width