Tutorial by Examples: c

A class constructor must have the same name as its class. Let's create a constructor for a class Person: class Person { String name; String gender; int age; Person(this.name, this.gender, this.age); } The example above is a simpler, better way of defining the constructor than the...
Dart functions may also be declared anonymously or nested. For example, to create a nested function, just open a new function block within an existing function block void outerFunction() { bool innerFunction() { /// Does stuff } } The function innerFunction may now be us...
Just as you're able to bind data from a view to the model, you can also bind props using the same v-bind directive for passing information from parent to child components. JS new Vue({ el: '#example', data: { msg: 'hello world' } }); Vue.component('child', { props:...
Here is an example of basic overriding in Python (for the sake of clarity and compatibility with both Python 2 and 3, using new style class and print with ()): class Parent(object): def introduce(self): print("Hello!") def print_name(self): print("Parent...
4.0 Instead of the ForEach-Object cmdlet, the here is also the possibility to use a ForEach method directly on object arrays like so (1..10).ForEach({$_ * $_}) or - if desired - the parentheses around the script block can be omitted (1..10).ForEach{$_ * $_} Both will result in the output ...
Having your scripts call Raycast directly may lead to problems if you need to change the collision matrices in the future, as you'll have to track down every LayerMask field to accommodate the changes. Depending on the size of your project, this may become a huge undertaking. Encapsulating Raycast ...
NativeScript’s global console variable lets you print values to your terminal for debugging. The simplest usage is passing a value to the console.log() function: console.log("hello world"); The console object has several other methods, including dump(), trace(), assert() and more. // ...
There are hundreds of settings that can be placed in my.cnf. For the 'lite' user of MySQL, they won't matter as much. Once your database becomes non-trivial, it is advisable to set the following parameters: innodb_buffer_pool_size This should be set to about 70% of available RAM (if you have a...
ALTER TABLE foo ENGINE=InnoDB; This converts the table, but does not take care of any differences between the engines. Most differences will not matter, especially for small tables. But for busier tables, other considerations should be considered. Conversion considerations
A branch is just a pointer to a commit, so you can freely move it around. To make it so that the branch is referring to the commit aabbcc, issue the command git reset --hard aabbcc Please note that this will overwrite your branch's current commit, and as so, its entire history. You might loose s...
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <circle r="30" cx="100" cy="100" fill="rgb(255, 0, 0)" stroke="rgb(0, 255, 0)" /> <rect x="200" y="200" w...
PrimitiveBoxed TypeMemory Size of primitive / boxedbooleanBoolean1 byte / 16 bytesbyteByte1 byte / 16 bytesshortShort2 bytes / 16 bytescharChar2 bytes / 16 bytesintInteger4 bytes / 16 byteslongLong8 bytes / 16 bytesfloatFloat4 bytes / 16 bytesdoubleDouble8 bytes / 16 bytes Boxed objects always requ...
UPDATE person SET state = 'NY' WHERE city = 'New York';
You can update multiple columns in a table in the same statement, separating col=val pairs with commas: UPDATE person SET country = 'USA', state = 'NY' WHERE city = 'New York';
Everything in .NET is an object, hence every type has ToString() method defined in Object class which can be overridden. Default implementation of this method just returns the name of the type: public class Foo { } var foo = new Foo(); Console.WriteLine(foo); // outputs Foo ToString() is i...
Using GNU grep grep -r 'pattern' <directory path> To also list line numbers of matches use -n option grep -rn 'pattern' <directory path> To search only files with particular glob pattern grep --include='*.txt' -r 'pattern' <directory path> Exclude file patterns or direc...
Say we are working on a class representing a Person by their first and last names. We have created a basic class to do this and implemented proper equals and hashCode methods. public class Person { private final String lastName; //invariant - nonnull private final String firstName; //in...
The Comparable<T> interface requires one method: public interface Comparable<T> { public int compareTo(T other); } And the Comparator<T> interface requires one method: public interface Comparator<T> { public int compare(T t1, T t2); } These two met...
Variables declared inside a function only exist (unless passed) inside that function. x <- 1 foo <- function(x) { y <- 3 z <- x + y return(z) } y Error: object 'y' not found Variables passed into a function and then reassigned are overwritten, but only insi...
Functions called within a function (ie subfunctions) must be defined within that function to access any variables defined in the local environment without being passed. This fails: bar <- function() { z <- x + y return(z) } foo <- function() { y <- 3 z <-...

Page 251 of 826