Tutorial by Examples: er

Well, if you want a switch/case construct, the most straightforward way to go is to use the good old if/else construct: def switch(value): if value == 1: return "one" if value == 2: return "two" if value == 42: return "the answer to...
Another way, which is very readable and elegant, but far less efficient than a if/else structure, is to build a class such as follows, that will read and store the value to compare with, expose itself within the context as a callable that will return true if it matches the stored value: class Switc...
SQL has various join types to specify whether (non-)matching rows are included in the result: INNER JOIN, LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL OUTER JOIN (the INNER and OUTER keywords are optional). The figure below underlines the differences between these types of joins: the blue area repres...
It is possible to perform ViewActions on a view using the perform method. The ViewActions class provides helper methods for the most common actions, like: ViewActions.click() ViewActions.typeText() ViewActions.clearText() For example, to click on the view: onView(...).perform(click()); onVi...
Inherits Specifies the base (or parent) class Public Class Person End Class Public Class Customer Inherits Person End Class 'One line notation Public Class Student : Inherits Person End Class Possible objects: Dim p As New Person Dim c As New Customer Dim s As New Student ...
Overridable Allows a property or method in a class to be overridden in a derived class. Public Class Person Public Overridable Sub DoSomething() Console.WriteLine("Person") End Sub End Class Overrides Overrides an Overridable property or method defined in the base...
Overloading is the creation of more than one procedure, instance constructor, or property in a class with the same name but different argument types. Class Person Overloads Sub Display(ByVal theChar As Char) ' Add code that displays Char data. End Sub Overloads Sub Display...
Public Interface IPerson Sub DoSomething() End Interface Public Class Customer Implements IPerson Public Sub DoSomething() Implements IPerson.DoSomething Console.WriteLine("Customer") End Sub End Class
In C, character constants and string literals are different things. A character surrounded by single quotes like 'a' is a character constant. A character constant is an integer whose value is the character code that stands for the character. How to interpret character constants with multiple charac...
Interface declaration for downloading a file public interface ApiInterface { @GET("movie/now_playing") Call<MovieResponse> getNowPlayingMovies(@Query("api_key") String apiKey, @Query("page") int page); // option 1: a resource relative to your bas...
# will retrieve my home path ENV['HOME'] # => "/Users/username" # will try retrieve the 'FOO' environment variable. If failed, will get 'bar' ENV.fetch('FOO', 'bar')
In Normal, type the following to delete a range of lines into a named register :10,20d a This will delete lines 10,20 in register "a. We can verify this by typing :reg This will show the text that was delete in register "a. To paste the contents in "a, just type "ap ...
0.18.0 Model is passed to subscriptions which means that every state change can modify subscriptions. import Html exposing ( Html, div, text, button ) import Html.Events exposing ( onClick ) import Time main : Program Never Model Msg main = Html.program { init = init ,...
If a recursive call goes "too deep", this results in a StackOverflowError. Java allocates a new frame for every method call on its thread's stack. However, the space of each thread's stack is limited. Too many frames on the stack leads to the Stack Overflow (SO). Example public static vo...
Since Laravel version 5.2.31 the web middleware is applied by default within the RouteServiceProvider (https://github.com/laravel/laravel/commit/5c30c98db96459b4cc878d085490e4677b0b67ed) In app/Providers/RouteServiceProvider.php you will find the following functions which apply the middleware on ev...
To open a new window, add the following code somewhere where you can keep a reference to the new window (I.E., the app delegate). Swift let storyboard:NSStoryboard = NSStoryboard(name: "Main", bundle: nil) guard let controller:NSWindowController = storyboard.instantiateControllerWithIde...
private final OkHttpClient client = new OkHttpClient(); public void run() throws Exception { RequestBody formBody = new FormBody.Builder() .add("search", "Jurassic Park") .build(); Request request = new Request.Builder() .url("https:...
If the type on which the static constructor is declared is generic, the static constructor will be called once for each unique combination of generic arguments. class Animal<T> { static Animal() { Console.WriteLine(typeof(T).FullName); } public static void Yawn...
with Ada.Text_IO; procedure Main is type Fruit is (Banana, Orange, Pear); X : Fruit := Orange; begin Ada.Text_IO.Put_Line (Fruit'Image (X)); end Main; Result ORANGE
with Ada.Text_IO; procedure Main is X : Integer := 17; begin Ada.Text_IO.Put_Line (Integer'Image (X)); end Main; Result 17

Page 184 of 417