Sweet.apex

  • Docs
  • Tutorials
Docs Menu
  • Sweet.apex Core
    • Transpilation
    • Grammar
    • Command
    • Config
  • Features
    • Action
    • Apex Doc
    • Array Creation
    • Aspect
    • Cast
    • Default Value
    • Enum
    • File
    • Function
    • Identity
    • Injection
    • Lambda
    • Log
    • Mod
    • Not Null
    • Operator
    • Optional
    • Reflection
    • Rethrow
    • Switch
    • Template String
    • Template
    • Script
    • Tagged String
    • Annotation
    • Nullable
    • Var
    • Val
    • Map Access
    • Constructor
    • Transaction
    • Destructure
    • Import Static
    • Pipeline
    • Varargs
    • Patch
    • Import As
  • Plugin Development
    • Feature
    • Test Case

Tagged String Guide

Tagged String

Feature Overview

This feature converts tagged strings into method calls.

Prerequisite

None

Sweet Apex Example

public class TaggedStringDemo {
    @tag
    public static String n(List items, List values) {
        return 'prefix__' + String.join(items, '');
    }

    public static void main() {
        String s = n`Name`;
    }
}

Transpiled Apex

public class TaggedStringDemo {
    public static String n(List items, List values) {
        return 'prefix__' + String.join(items, '');
    }
    public static void main() {
        String s = (String)TaggedStringDemo.n(new List{ 'Name' }, new List{  });
    }
}

Usage

Methods with @tag annotation should be public/global static and accept parameters of List and List.

Contribute on Github! Edit this section.