Tutorial by Examples: code

string sqrt = "\u221A"; // √ string emoji = "\U0001F601"; // 😁 string text = "\u0022Hello World\u0022"; // "Hello World" string variableWidth = "\x22Hello World\x22"; // "Hello World"
When a Java class overrides the equals method, it should override the hashCode method as well. As defined in the method's contract: Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, ...
Optional<String> optionalWithValue = Optional.of("foo"); optionalWithValue.ifPresent(System.out::println);//Prints "foo". Optional<String> emptyOptional = Optional.empty(); emptyOptional.ifPresent(System.out::println);//Does nothing.
The exit construct can be used to pass a return code to the executing environment. #!/usr/bin/php if ($argv[1] === "bad") { exit(1); } else { exit(0); } By default an exit code of 0 will be returned if none is provided, i.e. exit is the same as exit(0). As exit is not a ...
In the event that geolocation fails, your callback function will receive a PositionError object. The object will include an attribute named code that will have a value of 1, 2, or 3. Each of these numbers signifies a different kind of error; the getErrorCode() function below takes the PositionError....
In addition to .done, .fail and .always promise callbacks, which are triggered based on whether the request was successful or not, there is the option to trigger a function when a specific HTTP Status Code is returned from the server. This can be done using the statusCode parameter. $.ajax({ t...
You can have multiple versions of Xcode installed at the same time (including beta versions). Simply rename the application in Finder to avoid conflicts. Note: Installing Xcode from the App Store will tend to overwrite an existing version on your machine. You can also install Xcode from a direct ...
Abbreviated from https://blogs.dropbox.com/developers/2013/07/using-oauth-2-0-with-the-core-api/: Step 1: Begin authorization Send the user to this web page, with your values filled in: https://www.dropbox.com/oauth2/authorize?client_id=<app key>&response_type=code&redirect_uri=<...
In the same module Inside a module named "MyModule", Xcode generates a header named MyModule-Swift.h which exposes public Swift classes to Objective-C. Import this header in order to use the Swift classes: // MySwiftClass.swift in MyApp import Foundation // The class must be `public`...
If MyFramework contains Objective-C classes in its public headers (and the umbrella header), then import MyFramework is all that's necessary to use them from Swift. Bridging headers A bridging header makes additional Objective-C and C declarations visible to Swift code. When adding project files, ...
Markdown supports adding inline code like this, obtained by wrapping text in backticks: `code here` Alternatively, you can put your inline code between <code> and </code> HTML tags. Consider the following markdown code: `This` is an inline code block! <code>This</code> is...
You can create multiline code snippets by indenting each line with at least four spaces or one tab: #include <stdio.h> int main() { printf("Hello World!\n"); return 0; }
Some parsers allow code to be designated by adding three backticks before and after a section of code. ``` <p><em>This</em> is an HTML example!</p> ``` Optionally, many parsers allow adding syntax highlighting by specifying the code's language immediately after the firs...
Once you've paused execution on a breakpoint, you may want to follow execution line-by-line to observe what happens. Open your browser's Developer Tools and look for the Execution Control icons. (This example uses the icons in Google Chrome, but they'll be similar in other browsers.) Resume: Unpau...
While inside a Razor code block, the browser will only recognize HTML code if the code is escaped. Use @: for a Single line: @foreach(int number in Model.Numbers) { @:<h1>Hello, I am a header!</h1> } Use <text> ... </text> for Multi-line: @{ var number = 1; ...
Setting values Using Unicode directly var str: String = "I want to visit 北京, Москва, मुंबई, القاهرة, and 서울시. 😊" var character: Character = "🌍" Using hexadecimal values var str: String = "\u{61}\u{5927}\u{1F34E}\u{3C0}" // a大🍎π var character: Character = &quo...
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...
Python 2.x2.7 In Python 2 there are two variants of string: those made of bytes with type (str) and those made of text with type (unicode). In Python 2, an object of type str is always a byte sequence, but is commonly used for both text and binary data. A string literal is interpreted as a byte s...
select LastName, FirstName, from Person Returns message: Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from Person' at line 2. Getting a "1064 error" message from MySQL mean...
Let's say we have an interface for logging: interface Logger { function log($message); } Now say we have two concrete implementations of the Logger interface: the FileLogger and the ConsoleLogger. class FileLogger implements Logger { public function log($message) { // Append...

Page 1 of 21