Tutorial by Examples: ar

Instance variables are unique for each instance, while class variables are shared by all instances. class C: x = 2 # class variable def __init__(self, y): self.y = y # instance variable C.x # 2 C.y # AttributeError: type object 'C' has no attribute 'y' c1 = C(3) c1....
Supplying pow() with 3 arguments pow(a, b, c) evaluates the modular exponentiation ab mod c: pow(3, 4, 17) # 13 # equivalent unoptimized expression: 3 ** 4 % 17 # 13 # steps: 3 ** 4 # 81 81 % 17 # 13 For built-in types using modular exponentiation is only possible...
Using the strtotime() function combined with date() you can parse different English text descriptions to dates: // Gets the current date echo date("m/d/Y", strtotime("now")), "\n"; // prints the current date echo date("m/d/Y", strtotime("10 September 2...
Check whether a string is empty: if str.isEmpty { // do something if the string is empty } // If the string is empty, replace it with a fallback: let result = str.isEmpty ? "fallback string" : str Check whether two strings are equal (in the sense of Unicode canonical equivale...
To clear the storage, simply run localStorage.clear();
Functions can take parameters so that their functionality can be modified. Parameters are given as a comma separated list with their types and names defined. func magicNumber(number1: Int) { print("\(number1) Is the magic number") } Note: The \(number1) syntax is basic String I...
To pass data from the current view controller to the next new view controller (not a previous view controller) using segues, first create a segue with an identifier in the relevant storyboard. Override your current view controller's prepareForSegue method. Inside the method check for the segue you j...
Install Meteor On OS X and Linux Install the latest official Meteor release from your terminal: $ curl https://install.meteor.com/ | sh On Windows Download the official Meteor installer here. Create your app Once you've installed Meteor, create a project: $ meteor create myapp Run i...
$url = "https://api.dropboxapi.com/2/sharing/share_folder" $req = [System.Net.HttpWebRequest]::Create($url) $req.headers["Authorization"] = "Bearer <ACCESS_TOKEN>" $req.Method = "POST" $req.ContentType = "application/json" $enc = [system...
int a; printf("%d", a); The variable a is an int with automatic storage duration. The example code above is trying to print the value of an uninitialized variable (a was never initialized). Automatic variables which are not initialized have indeterminate values; accessing these can le...
This code creates a sticky footer. When the content doesn't reach the end of the viewport, the footer sticks to the bottom of the viewport. When the content extends past the bottom of the viewport, the footer is also pushed out of the viewport. View Result HTML: <div class="header"&gt...
Browse to File > New > Project to bring you up the New Project dialog. Navigate to Visual C# > iOS > iPhone and select Single View App: Give your app a Name and press OK to create your project. Select the Mac Agent icon from the toolbar, as illustrated below: Select the Mac tha...
The !important declaration is used to override the usual specificity in a style sheet by giving a higher priority to a rule. Its usage is: property : value !important; #mydiv { font-weight: bold !important; /* This property won't be overridden by the ...
When multi-line (?m) modifier is turned off, ^ matches only the input string's beginning: For the regex ^He The following input strings match: Hedgehog\nFirst line\nLast line Help me, please He And the following input strings do not match: First line\nHedgehog\nLast line IHedgehog ...
If you need to use the ^ character in a character class (Character classes ), either put it somewhere other than the beginning of the class: [12^3] Or escape the ^ using a backslash \: [\^123] If you want to match the caret character itself outside a character class, you need to escape it: ...
The searched CASE returns results when a boolean expression is TRUE. (This differs from the simple case, which can only check for equivalency with an input.) SELECT Id, ItemId, Price, CASE WHEN Price < 10 THEN 'CHEAP' WHEN Price < 20 THEN 'AFFORDABLE' ELSE 'EXPENSIVE' E...
In MATLAB, the most basic data type is the numeric array. It can be a scalar, a 1-D vector, a 2-D matrix, or an N-D multidimensional array. % a 1-by-1 scalar value x = 1; To create a row vector, enter the elements inside brackets, separated by spaces or commas: % a 1-by-4 row vector v = [1, 2...
List Assignment If you are familiar with Perl, C, or Java, you might think that Bash would use commas to separate array elements, however this is not the case; instead, Bash uses spaces: # Array in Perl my @array = (1, 2, 3, 4); # Array in Bash array=(1 2 3 4) Create an array with new ...
Print element at index 0 echo "${array[0]}" 4.3 Print last element using substring expansion syntax echo "${arr[@]: -1 }" 4.3 Print last element using subscript syntax echo "${array[-1]}" Print all elements, each quoted separately echo "${array[@...
$.ajax({ url: 'https://api.dropboxapi.com/2/sharing/add_folder_member', type: 'POST', processData: false, data: JSON.stringify({"shared_folder_id": "84528192421","members": [{"member": {".tag": "email","email":...

Page 11 of 218