RSS

Tag Archives: swift

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


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
   is
  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.

Advertisements
 
Leave a comment

Posted by on June 21, 2014 in Programming

 

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