Tutorial by Examples: ces

A class in Scala is a 'blueprint' of a class instance. An instance contains the state and behavior as defined by that class. To declare a class: class MyClass{} // curly braces are optional here as class body is empty An instance can be instantiated using new keyword: var instance = new MyClas...
It is very convenient to use extension methods with interfaces as implementation can be stored outside of class and all it takes to add some functionality to class is to decorate class with interface. public interface IInterface { string Do() } public static class ExtensionMethods{ pu...
Different operations with data are done using special classes. Most of the classes belong to one of the following groups: classification algorithms (derived from sklearn.base.ClassifierMixin) to solve classification problems regression algorithms (derived from sklearn.base.RegressorMixin) to so...
PHP 7 introduces a new kind of operator, which can be used to compare expressions. This operator will return -1, 0 or 1 if the first expression is less than, equal to, or greater than the second expression. // Integers print (1 <=> 1); // 0 print (1 <=> 2); // -1 print (2 <=> 1...
A method defined in an interface is by default public abstract. When an abstract class implements an interface, any methods which are defined in the interface do not have to be implemented by the abstract class. This is because a class that is declared abstract can contain abstract method declaratio...
s=this.getChildByName("garbage"); if (s.parent==this) {...} getChildByName() is one of the many functions that can return null if an error occurred when processing its input. Therefore, if you are receiving an object from any function that can possibly return null, check for null first...
Overload resolution occurs after name lookup. This means that a better-matching function will not be selected by overload resolution if it loses name lookup: void f(int x); struct S { void f(double x); void g() { f(42); } // calls S::f because global f is not visible here, ...
class File(): def __init__(self, filename, mode): self.filename = filename self.mode = mode def __enter__(self): self.open_file = open(self.filename, self.mode) return self.open_file def __exit__(self, *args): self.open_file.close() ...
Declaring a generic interface interface IResult<T> { wasSuccessfull: boolean; error: T; } var result: IResult<string> = .... var error: string = result.error; Generic interface with multiple type parameters interface IRunnable<T, U> { run(input: T): U; } ...
Using the mmap module allows the user to randomly access locations in a file by mapping the file into memory. This is an alternative to using normal file operations. import mmap with open('filename.ext', 'r') as fd: # 0: map the whole file mm = mmap.mmap(fd.fileno(), 0) # print ...
Accessibility of symbols declared in a module can be controlled using private and public attributes and statement. Syntax of the statement form: !all symbols declared in the module are private by default private !all symbols declared in the module are public by default public !symbols in t...
#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...
git diff HEAD^ HEAD This will show the changes between the previous commit and the current commit.
New or detached objects may be added to the session using add(): session.add(obj) A sequence of objects may be added using add_all(): session.add_all([obj1, obj2, obj3]) An INSERT will be emitted to the database during the next flush, which happens automatically. Changes are persisted when t...
To delete persisted objects use delete(): session.delete(obj) Actual deletion from the database will happen on next flush.
SharedPreferences allows you to store primitive data types only (boolean, float, long, int, String, and string set). You cannot store more complex objects in SharedPreferences, and as such is really meant to be a place to store user settings or similar, it's not meant to be a database to keep user d...
Because of the reasons explained in Remarks section you can't simply do this (unless you want to count occurrences of a specific code-unit): int count = text.Count(x => x == ch); You need a more complex function: public static int CountOccurrencesOf(this string text, string character) { ...
You can bind to a property of an ancestor in the visual tree by using a RelativeSource binding. The nearest control higher in the visual tree which has the same type or is derived from the type you specify will be used as the binding's source: <Grid Background="Blue"> <Grid ...
Interfaces may have variant type parameters. interface IEnumerable<out T> { // ... } interface IComparer<in T> { // ... } but classes and structures may not class BadClass<in T1, out T2> // not allowed { } struct BadStruct<in T1, out T2> // not allo...
We create a new concurrent process by calling the spawn function. The spawn function will get as parameter a function Fun that the process will evaluate. The return value of the spawn function is the created process identifier (pid). 1> Fun = fun() -> 2+2 end. #Fun<erl_eval.20.52032458&gt...

Page 10 of 40