Tutorial by Examples: ble

float float is an alias to the .NET datatype System.Single. It allows IEEE 754 single-precision floating point numbers to be stored. This data type is present in mscorlib.dll which is implicitly referenced by every C# project when you create them. Approximate range: -3.4 × 1038 to 3.4 × 1038 Deci...
Modules can have a special variable named __all__ to restrict what variables are imported when using from mymodule import *. Given the following module: # mymodule.py __all__ = ['imported_by_star'] imported_by_star = 42 not_imported_by_star = 21 Only imported_by_star is imported when usi...
Scope A variable can be declared (in increasing visibility level): At procedure level, using the Dim keyword in any procedure; a local variable. At module level, using the Private keyword in any type of module; a private field. At instance level, using the Friend keyword in any type of class m...
By default error message appears below textbox in <div class="help-block"></div> on keyUp or after pressing submit button if any validation constraints aren't met. Sometimes we want a message on submit only i.e. no validation at onKeyup event. Let's check yii2/widgets/ActiveF...
The double-negation !! is not a distinct JavaScript operator nor a special syntax but rather just a sequence of two negations. It is used to convert the value of any type to its appropriate true or false Boolean value depending on whether it is truthy or falsy. !!1 // true !!0 ...
If a name is bound inside a function, it is by default accessible only within the function: def foo(): a = 5 print(a) # ok print(a) # NameError: name 'a' is not defined Control flow constructs have no impact on the scope (with the exception of except), but accessing variable that w...
One of the main differences between lists and tuples in Python is that tuples are immutable, that is, one cannot add or modify items once the tuple is initialized. For example: >>> t = (1, 4, 9) >>> t[0] = 2 Traceback (most recent call last): File "<stdin>", l...
There is already a function sum(). As a result, if we name a variable with the same name sum = 1+3; and if we try to use the function while the variable still exists in the workspace A = rand(2); sum(A,1) we will get the cryptic error: Subscript indices must either be real positive integer...
traverse_ executes an Applicative action for every element in a Foldable structure. It ignores the action's result, keeping only the side-effects. (For a version which doesn't discard results, use Traversable.) -- using the Writer applicative functor (and the Sum monoid) ghci> runWriter $ trave...
Use of global variables is generally discouraged. It makes your program more difficult to understand, and harder to debug. But sometimes using a global variable is acceptable. global.h #ifndef GLOBAL_DOT_H /* This is an "include guard" */ #define GLOBAL_DOT_H /** * This tells ...
This type of Singleton is thread safe, and prevents unnecessary locking after the Singleton instance has been created. Java SE 5 public class MySingleton { // instance of class private static volatile MySingleton instance = null; // Private constructor private MySingleton()...
To create a pure JSON table you need to provide a single field with the type JSONB: CREATE TABLE mytable (data JSONB NOT NULL); You should also create a basic index: CREATE INDEX mytable_idx ON mytable USING gin (data jsonb_path_ops); At this point you can insert data in to the table and que...
You can use traits to modify methods of a class, using traits in stackable fashion. The following example shows how traits can be stacked. The ordering of the traits are important. Using different order of traits, different behavior is achieved. class Ball { def roll(ball : String) = println(&q...
The table-layout property changes the algorithm that is used for the layout of a table. Below an example of two tables both set to width: 150px: The table on the left has table-layout: auto while the one on the right has table-layout: fixed. The former is wider than the specified width (210px in...
Arrays can have the allocatable attribute: ! One dimensional allocatable array integer, dimension(:), allocatable :: foo ! Two dimensional allocatable array real, dimension(:,:), allocatable :: bar This declares the variable but does not allocate any space for it. ! We can specify the bounds...
To create a join table between students and courses, run the command: $ rails g migration CreateJoinTableStudentCourse student course This will generate the following migration: class CreateJoinTableStudentCourse < ActiveRecord::Migration[5.0] def change create_join_table :students, ...
To add a new column name to the users table, run the command: rails generate migration AddNameToUsers name This generates the following migration: class AddNameToUsers < ActiveRecord::Migration[5.0] def change add_column :users, :name, :string end end When the migration name i...
To remove existing column name from users table, run the command: rails generate migration RemoveNameFromUsers name:string This will generate the following migration: class RemoveNameFromUsers < ActiveRecord::Migration[5.0] def change remove_column :users, :name, :string end end ...
To add a reference to a team to the users table, run this command: $ rails generate migration AddTeamRefToUsers team:references This generates the following migration: class AddTeamRefToUsers < ActiveRecord::Migration[5.0] def change add_reference :users, :team, foreign_key: true ...
To create a new users table with the columns name and salary, run the command: rails generate migration CreateUsers name:string salary:decimal This will generate the following migration: class CreateUsers < ActiveRecord::Migration[5.0] def change create_table :users do |t| t.s...

Page 6 of 62