Apple Swift: top 5 familiar code patterns for java or C# coders

21 Jun

Apple just released its new Swift programming languages, and java and C# coders may be happy about this as there are many features that you will feel familiar with:

  • Type inference and var keyword:

var str =”Some String”
var iValue = 32

  • Nullable (Nil-able)

int? a=3;

  • Comments and block comments

// Single line comment
/* This
  block comment

  • Ternary Conditional Operators

boolean AreYouHappy = TodayIsWeekend? true: false;

  • String format (String Interpolation): the C# {0} equivalent in String.Format():

int money = 123456
string money_str = “We have \(money) dollars”  // We have 123456 dollars

See online documentation here.

Leave a comment

Posted by on June 21, 2014 in Programming


Tags: , , , , , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: