Tutorial by Examples: def

You can customize your theme’s color palette. Using framework APIs 5.0 <style name="AppTheme" parent="Theme.Material"> <item name="android:colorPrimary">@color/primary</item> <item name="android:colorPrimaryDark">@color/pri...
In order to define a variable inside a linq expression, you can use the let keyword. This is usually done in order to store the results of intermediate sub-queries, for example: int[] numbers = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; var aboveAverages = from number in numbers l...
Value Type (where T : struct) The built-in primitive data types, such as char, int, and float, as well as user-defined types declared with struct, or enum. Their default value is new T() : default(int) // 0 default(DateTime) // 0001-01-01 12:00:00 AM default(char) // '...
2.2 func removeCharactersNotInSetFromText(text: String, set: Set<Character>) -> String { return String(text.characters.filter { set.contains( $0) }) } let text = "Swift 3.0 Come Out" var chars = Set([Character]("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ&...
To make a Haskell program executable you must provide a file with a main function of type IO () main :: IO () main = putStrLn "Hello world!" When Haskell is compiled it examines the IO data here and turns it into a executable. When we run this program it will print Hello world!. If y...
The default namespace is the namespace corresponding to the absence of any prefix. It can be declared with the special xmlns attribute. <?xml version="1.0"?> <foo xmlns="http://www.example.com/my-namespace"> <!-- the element foo is in the namespace htt...
We can use Predefined Constants for Date format in date() instead of the conventional date format strings since PHP 5.1.0. Predefined Date Format Constants Available DATE_ATOM - Atom (2016-07-22T14:50:01+00:00) DATE_COOKIE - HTTP Cookies (Friday, 22-Jul-16 14:50:01 UTC) DATE_RSS - RSS (Fri, 22...
Define AccumulatorParam import org.apache.spark.AccumulatorParam object StringAccumulator extends AccumulatorParam[String] { def zero(s: String): String = s def addInPlace(s1: String, s2: String)= s1 + s2 } Use: val accumulator = sc.accumulator("")(StringAccumulator) sc.pa...
Define AccumulatorParam: from pyspark import AccumulatorParam class StringAccumulator(AccumulatorParam): def zero(self, s): return s def addInPlace(self, s1, s2): return s1 + s2 accumulator = sc.accumulator("", StringAccumulator()) def add(x): gl...
demoApp.directive('demoDirective', function () { var directiveDefinitionObject = { multiElement: priority: terminal: scope: {}, bindToController: {}, controller: controllerAs: require: restrict: templateNamespace: template: templateU...
A type has value semantics if the object's observable state is functionally distinct from all other objects of that type. This means that if you copy an object, you have a new object, and modifications of the new object will not be in any way visible from the old object. Most basic C++ types have v...
PL/SQL (Procedural Language/Structured Query Language) is Oracle Corporation's procedural extension for SQL and the Oracle relational database. PL/SQL is available in Oracle Database (since version 7), TimesTen in-memory database (since version 11.2.1), and IBM DB2 (since version 9.7). The basic un...
There are several possibilities and conventions to name an enumeration. The first is to use a tag name just after the enum keyword. enum color { RED, GREEN, BLUE }; This enumeration must then always be used with the keyword and the tag like this: enum color chosenColor = RE...
This example shows how to use the default logging api. import java.util.logging.Level; import java.util.logging.Logger; public class MyClass { // retrieve the logger for the current class private static final Logger LOG = Logger.getLogger(MyClass.class.getName()); pub...
Defining a method in Ruby 2.x returns a symbol representing the name: class Example puts def hello end end #=> :hello This allows for interesting metaprogramming techniques. For instance, methods can be wrapped by other methods: class Class def logged(name) original_method...
$parameters = @{ From = '[email protected]' To = '[email protected]' Subject = 'Email Subject' Attachments = @('C:\files\samplefile1.txt','C:\files\samplefile2.txt') BCC = '[email protected]' Body = 'Email body' BodyAsHTML = $False CC = '[email protected]' Credential = Get-Crede...
When Oracle implicitly converts from a DATE to a string or vice-versa (or when TO_CHAR() or TO_DATE() are explicitly called without a format model) the NLS_DATE_FORMAT session parameter will be used as the format model in the conversion. If the literal does not match the format model then an excepti...
macro(set_my_variable _INPUT) if("${_INPUT}" STREQUAL "Foo") set(my_output_variable "foo") else() set(my_output_variable "bar") endif() endmacro(set_my_variable) Use the macro: set_my_variable("Foo") message(STATUS ${my_outpu...
The normal orElse method takes an Object, so you might wonder why there is an option to provide a Supplier here (the orElseGet method). Consider: String value = "something"; return Optional.ofNullable(value) .orElse(getValueThatIsHardToCalculate()); // returns "some...
#include <stdio.h> #define ARRLEN (10) int main (void) { int n[ ARRLEN ]; /* n is an array of 10 integers */ size_t i, j; /* Use size_t to address memory, that is to index arrays, as its guaranteed to be wide enough to address all of the possible availab...

Page 6 of 27