Tutorial by Examples: def

Using the AdvancedRTFEditorKit library you can serialize a DefaultStyledDocument to an RTF string. try { DefaultStyledDocument writeDoc = new DefaultStyledDocument(); writeDoc.insertString(0, "Test string", null); AdvancedRTFEditorKit kit = new AdvancedRTFEditorKit(); ...
Defining a new protocol: @protocol NewProtocol - (void)protocolMethod:(id)argument; - (id)anotherMethod; @end
You define a class like this: class Dog {} A class can also be a subclass of another class: class Animal {} class Dog: Animal {} In this example, Animal could also be a protocol that Dog conforms to.
In addition to named imports, you can provide a default export. // circle.js export const PI = 3.14; export default function area(radius) { return PI * radius * radius; } You can use a simplified syntax to import the default export. import circleArea from './circle'; console.log(circle...
In ECMAScript 6, when using the module syntax (import/export), each file becomes its own module with a private namespace. Top-level functions and variables do not pollute the global namespace. To expose functions, classes, and variables for other modules to import, you can use the export keyword. /...
collections.defaultdict(default_factory) returns a subclass of dict that has a default value for missing keys. The argument should be a function that returns the default value when called with no arguments. If there is nothing passed, it defaults to None. >>> state_capitals = collections.d...
A block that performs addition of two double precision numbers, assigned to variable addition: double (^addition)(double, double) = ^double(double first, double second){ return first + second; }; The block can be subsequently called like so: double result = addition(1.0, 2.0); // result =...
By default, local variables that are not explicitly specified in the capture list, cannot be accessed from within the lambda body. However, it is possible to implicitly capture variables named by the lambda body: int a = 1; int b = 2; // Default capture by value [=]() { return a + b; }; // OK;...
Annotation types are defined with @interface. Parameters are defined similar to methods of a regular interface. @interface MyAnnotation { String param1(); boolean param2(); int[] param3(); // array parameter } Default values @interface MyAnnotation { String param1() defau...
Available in the standard library as defaultdict from collections import defaultdict d = defaultdict(int) d['key'] # 0 d['key'] = 5 d['key'] # 5 d = defaultdict(lambda: 'empty') d['key'] # 'empty' d['key'] = 'full' ...
The "default" for constructors is that they do not have any arguments. In case you do not specify any constructor, the compiler will generate a default constructor for you. This means the following two snippets are semantically equivalent: public class TestClass { private String tes...
5 It allows us to define a property in an existing object using a property descriptor. var obj = { }; Object.defineProperty(obj, 'foo', { value: 'foo' }); console.log(obj.foo); Console output foo Object.defineProperty can be called with the following options: Object.definePropert...
At first glance it may appear that null and undefined are basically the same, however there are subtle but important differences. undefined is the absence of a value in the compiler, because where it should be a value, there hasn't been put one, like the case of an unassigned variable. undefined...
In classes, super.foo() will look in superclasses only. If you want to call a default implementation from a superinterface, you need to qualify super with the interface name: Fooable.super.foo(). public interface Fooable { default int foo() {return 3;} } public class A extends Object impl...
The (?(DEFINE)...) construct lets you define subpatterns you may reference later through recursion. When encountered in the pattern it will not be matched against. This group should contain named subpattern definitions, which will be accessible only through recursion. You can define grammars this w...
BuildConfigField Gradle allows buildConfigField lines to define constants. These constants will be accessible at runtime as static fields of the BuildConfig class. This can be used to create flavors by defining all fields within the defaultConfig block, then overriding them for individual build fla...
You can combine object initializers with constructors to initialize types if necessary. Take for example a class defined as such: public class Book { public string Title { get; set; } public string Author { get; set; } public Book(int id) { //do things } // the...
A compiler symbol is a keyword that is defined at compile-time that can be checked for to conditionally execute specific sections of code. There are three ways to define a compiler symbol. They can be defined via code: #define MYSYMBOL They can be defined in Visual Studio, under Project Propert...
Dim array(9) As Integer ' Defines an array variable with 10 Integer elements (0-9). Dim array = New Integer(10) {} ' Defines an array variable with 11 Integer elements (0-10) 'using New. Dim array As Integer() = {1, 2, 3, 4} ' Defines an Integer array variable a...
Code first allows you to create your entities (classes) without using a GUI designer or a .edmx file. It is named Code first, because you can create your models first and Entity framework will create database according to mappings for you automatically. Or you can also use this approach with existin...

Page 3 of 27