RDC11006 — Ambiguous concatenation
Severity: Information · Family: RDC (Rubberduck Core analyzers) ·
Raised by: AmbiguousConcatenationAnalyzer
The + operator is given two String values, and joins them.
+ adds numbers, and joins strings: which one it does depends on the types of its two operands (MS-VBAL §5.6.9.3 Arithmetic Operators). A reader has to
know both types to know what the line does, and the same line does the other thing when one of the operands is changed to a number: "1" + "2" is "12", but
"1" + 2 is 3. The & operator always joins, whatever it is given, and says so.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
Two String values are joined with +. |
fullName = firstName + " " + lastName |
Use &: fullName = firstName & " " & lastName. |
See also
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca