Tutorial by Examples: com

You can compare BigIntegers same as you compare String or other objects in Java. For example: BigInteger one = BigInteger.valueOf(1); BigInteger two = BigInteger.valueOf(2); if(one.equals(two)){ System.out.println("Equal"); } else{ System.out.println("Not Equal"...
async functions do not replace the Promise type; they add language keywords that make promises easier to call. They are interchangeable: async function doAsyncThing() { ... } function doPromiseThing(input) { return new Promise((r, x) => ...); } // Call with promise syntax doAsyncThing() ...
If value types are assigned to variables of type object they are boxed - the value is stored in an instance of a System.Object. This can lead to unintended consequences when comparing values with ==, e.g.: object left = (int)1; // int in an object box object right = (int)1; // int in an object bo...
The editor.apply() method is asynchronous, while editor.commit() is synchronous. Obviously, you should call either apply() or commit(). 2.3 SharedPreferences settings = getSharedPreferences(PREFS_FILE, MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean(PREF_CONS...
\bfoo\b will match the complete word with no alphanumeric and _ preceding or following by it. Taking from regularexpression.info There are three different positions that qualify as word boundaries: Before the first character in the string, if the first character is a word character. After...
Tuples can be compared based on their elements. As an example, an enumerable whose elements are of type Tuple can be sorted based on comparisons operators defined on a specified element: List<Tuple<int, string>> list = new List<Tuple<int, string>>(); list.Add(new Tuple<...
To use the IronPython command line, open ipy.exe or ipy64.exe. Both files are located in the path that was selected during installation. By default they will be located at C:\Program Files\IronPython 2.7\. Then start writing your statements directly in the IronPython command line. For example: pr...
Arrays You can iterate over nested arrays: [[1, 2], [3, 4]].each { |(a, b)| p "a: #{ a }", "b: #{ b }" } The following syntax is allowed too: [[1, 2], [3, 4]].each { |a, b| "a: #{ a }", "b: #{ b }" } Will produce: "a: 1" "b: 2" ...
DateTime date1 = new DateTime(2009, 8, 1, 0, 0, 0); DateTime date2 = new DateTime(2009, 8, 1, 12, 0, 0); int result = DateTime.Compare(date1, date2); string relationship; if (result < 0) relationship = "is earlier than"; else if (result == 0) relationship = "is the...
The following example demonstrates the use of a BackgroundWorker to update a WinForms ProgressBar. The backgroundWorker will update the value of the progress bar without blocking the UI thread, thus showing a reactive UI while work is done in the background. namespace BgWorkerExample { public...
Single line comments are preceded by --, and go until the end of the line: SELECT * FROM Employees -- this is a comment WHERE FName = 'John'
Multi-line code comments are wrapped in /* ... */: /* This query returns all employees */ SELECT * FROM Employees It is also possible to insert such a comment into the middle of a line: SELECT /* all columns: */ * FROM Employees
As Handlers are used to send Messages and Runnables to a Thread's message queue it's easy to implement event based communication between multiple Threads. Every Thread that has a Looper is able to receive and process messages. A HandlerThread is a Thread that implements such a Looper, for example th...
Elixir doesn't have loops. Instead of them for lists there are great Enum and List modules, but there are also List Comprehensions. List Comprehensions can be useful to: create new lists iex(1)> for value <- [1, 2, 3], do: value + 1 [2, 3, 4] filtering lists, using guard expressi...
You can broadcast more complex messages by serializing the payload before you publish it: // definition of a message public class ChatMessage { public Guid Id { get; set; } public string User { get; set; } public string Text { get; set; } } // grab an instance of an ISubscriber...
StackExchange.Redis also supports sending bytes over the pub/sub channel, here we use protobuf-net to serialize our message to a byte array before sending it: // definition of a message (marked up with Protobuf attributes) [ProtoContract] public class ChatMessage { [ProtoMember(1)] pub...
NSString *urlString = @"https://www.stackoverflow.com"; NSURL *myUrl = [NSURL URLWithString: urlString]; NSURL *myUrl2 = [NSURL URLWithString: urlString]; if ([myUrl isEqual:myUrl2]) return YES;
For simple array comparison you can use JSON stringify and compare the output strings: JSON.stringify(array1) === JSON.stringify(array2) Note: that this will only work if both objects are JSON serializable and do not contain cyclic references. It may throw TypeError: Converting circular struct...
Partial functions are often used to define a total function in parts: sealed trait SuperType case object A extends SuperType case object B extends SuperType case object C extends SuperType val pfA: PartialFunction[SuperType, Int] = { case A => 5 } val pfB: PartialFunction[SuperType,...
To perform actions in Django using commandline or other services (where the user/request is not used), you can use the management commands. Django modules can be imported as needed. For each command a separate file needs to be created: myapp/management/commands/my_command.py (The management and...

Page 9 of 65