2014-01-25 6 views
5

Gibt es eine Möglichkeit, Ruby-Stil, String-Interpolation in AppleScript zu erreichen? Ich brauche eine flexible Möglichkeit, String-Muster zu erstellen.Ruby-Stil String-Interpolation in AppleScript

Rubin:

fn = "john" 
=> "john" 

ln = "doe" 
=> "doe" 

addresses = [] 
=> [] 

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

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

Apple:

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

set theAddresses to {} 

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

Antwort

4

AFAIK gibt es keine String-Interpolation in Applescript. Das Äquivalent würde etwa so aussehen:

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]"}