8

Is there a way to achieve Ruby-style, string interpolation in AppleScript? I need a flexible way of creating string patterns.

Ruby:

fn = "john"
=> "john"

ln = "doe"
=> "doe"

addresses = []
=> []

addresses << "#{fn[0]}#{ln}@company.com"
=> ["[email protected]"]

addresses << "#{fn}.#{ln}@company.com"
=> ["[email protected]", "[email protected]"]

AppleScript:

set fn to "john"
set ln to "doe"

set theAddresses to {}

# [email protected]
copy [something here] & "@company.com" to the end of theAddresses

1 Answer 1

6

AFAIK there's no string interpolation in AppleScript. The equivalent would be something like this:

copy first character of fn & ln & "@company.com" to the end of theAddresses
copy fn & "." & ln & "@company.com" to the end of theAddresses

# {"[email protected]", "[email protected]"}
Sign up to request clarification or add additional context in comments.

2 Comments

This is really sad. Almost all other languages start to support string interpolation. Apple simply stopped developing AppleScript.
@FranklinYu yes, they keep limiting users more and more. macOS has become a very controlled environment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.