Tutorial by Examples: al

For the example, lets say that we have a List of type String that contains four elements: "hello, ", "how ", "are ", "you?" The best way to iterate over each element is by using a for-each loop: public void printEachElement(List<String> list){ for...
#include <iostream> long double operator"" _km(long double val) { return val * 1000.0; } long double operator"" _mi(long double val) { return val * 1609.344; } int main() { std::cout << "3 km = " << 3.0_km << " m...
options = { "x": ["a", "b"], "y": [10, 20, 30] } Given a dictionary such as the one shown above, where there is a list representing a set of values to explore for the corresponding key. Suppose you want to explore "x"="a" w...
A string can be used as a separator to join a list of strings together into a single string using the join() method. For example you can create a string where each element in a list is separated by a space. >>> " ".join(["once","upon","a","tim...
ANTLR is distributed as a Java Jar file It can be downloaded here. As ANTLR is compiled as a jar file it subsequently requires the Java runtime environment to operate, if you do not have It can be downloaded here. Once the ANTLR JAR file has been downloaded you can run ANTLR from the command line i...
If your application is available in different languages, you usually show the current locale in the URL. scope '/(:locale)', locale: /#{I18n.available_locales.join('|')}/ do root 'example#root' # other routes end Your root will be accessible via the locales defined in I18n.available_l...
From Apple documentation: Use the CTCallCenter class to obtain a list of current cellular calls, and to respond to state changes for calls such as from a dialing state to a connected state. Such state changes are known as cellular call events. The purpose of CTCallCenter is to give the develop...
public static void Main(string[] args) { var studentList = new List<Student>(); studentList.Add(new Student("Scott", "Nuke")); studentList.Add(new Student("Vincent", "King")); studentList.Add(new Student("Craig", "Be...
If you are given a JSON string : val str = """{ | "name" : "Jsony McJsonface", | "age" : 18, | "hobbies" : [ "Fishing", "Hunting", "Camping" ], | "pet" : { | ...
Self-referential association is used to associate a model with itself. The most frequent example would be, to manage association between a friend and his follower. ex. rails g model friendship user_id:references friend_id:integer now you can associate models like; class User < ActiveRecord:...
// Example of raw dynamic size array. It's generally better to use std::vector. #include <algorithm> // std::sort #include <iostream> using namespace std; auto int_from( istream& in ) -> int { int x; in >> x; return x; } auto main() -> int { ...
Because in .NET 3.5 and older you don't have Lazy<T> class you use the following pattern: public class Singleton { private Singleton() // prevents public instantiation { } public static Singleton Instance { get { return Nested.instanc...
RVM is a great tool to manage your ruby versions and set up your working environment. Assuming you already have RVM installed, to get the latest version of ruby, which is needed for these examples, open a terminal and run: $ rvm get stable $ rvm install ruby --latest Check your ruby version by...
LISP and Scheme's greatest advantage over other mainstream programming language is their macro system. Unlike the C preprocessor and other macro languages, Scheme macros take parsed code as input and return expanded code as output. This is one of the applications of Scheme's “code is data” phrase, a...
In this example we want to create a class that will generate and output to console, a random number between a range of two integers which are passed as arguments during the initialization. public class SimpleRangeRandom implements Runnable { private int min; private int max; pr...
When you implement java.io.Serializable interface to make a class serializable, the compiler looks for a static final field named serialVersionUID of type long. If the class doesn't have this field declared explicitly then the compiler will create one such field and assign it with a value which come...
Installing Tcl 8.6.4 on Windows : The easiest way to get Tcl on a windows machine is to install the ActiveTcl distribution from ActiveState. Navigate to www.activestate.com and follow the links to download the Free Community Edition of ActiveTcl for Windows (choose 32/64 bit version app...
if v:version >= 704 " Do something if Vim is the right version. endif if has('patch666') " Do something if Vim has the right patch-level. endif if has('feature') " Do something if Vim is built with 'feature'. endif See :help has-patch and :help feature-li...
Types & Protocols Type and protocol names should start with an uppercase letter. Example: protocol Collection {} struct String {} class UIView {} struct Int {} enum Color {} Everything else... Variables, constants, functions and enumeration cases should start with a lowercase letter. Exa...
The angular.equals function compares and determines if 2 objects or values are equal, angular.equals performs a deep comparison and returns true if and only if at least 1 of the following conditions is met. angular.equals(value1, value2) If the objects or values pass the === comparison If b...

Page 79 of 269