Tagged: language features

Java 7 launches – new language features introduced

Java 7 is now officially available as of July 28th 2011. The intent of this blog entry is to introduce the new language features. For further details, consult the Java 7 SDK. Binary Literals Underscores in Numeric Literals Strings in Switch Statements Type Inference for Generic Instance Creation Try-With-Resources Improved Exception Handling Improved Compiler Warnings and Errors When Using Non-Reifiable Formal Parameters with Varargs Methods Binary Literals [Official Docs] Long awaited, Java now allows for integral literals (byte, short, int, and long) to be expressed in binary.… Read the rest

Array unpacking in PHP

One of PHP’s less known language constructs is list(), very useful for unpacking indexed arrays. Consider the following simple example denoting its usage: <?php //populate an array with values $record= array('me', '1.800.123.4567', 'me@example.com'); //unpack the array into variables, skipping the phone number list($name, , $email) = $record; //print the output echo("name: $name; email: $email"); ?> This clean, readable, scalable approach is great for processing data records, unpacking an SQL result row, etc.… Read the rest