Tutorial by Examples: cas

uses SysUtils; var S1, S2: string; begin S1 := 'Foo'; S2 := LowerCase(S1); // S2 := 'foo'; S1 := UpperCase(S2); // S1 := 'FOO';
- var friends = 10 case friends when 0 p you have no friends when 1 p you have a friend default p you have #{friends} friends Result is: <p>you have 10 friends</p>
Also known as triple equals. This operator does not test equality, but rather tests if the right operand has an IS A relationship with the left operand. As such, the popular name case equality operator is misleading. This SO answer describes it thus: the best way to describe a === b is "if I ...
At its most basic level, Unit Testing in any language provides assertions against some known or expected output. function assert( outcome, description ) { var passFail = outcome ? 'pass' : 'fail'; console.log(passFail, ': ', description); return outcome; }; The popular assertio...
Java provides the instanceof operator to test if an object is of a certain type, or a subclass of that type. The program can then choose to cast or not cast that object accordingly. Object obj = Calendar.getInstance(); long time = 0; if(obj instanceof Calendar) { time = ((Calendar)obj).ge...
add permission in your manifest file <uses-permission android:name="android.permission.BLUETOOTH" /> In your Fragment(or Activity) Add the receiver method private BroadcastReceiver mBluetoothStatusChangedReceiver = new BroadcastReceiver() { @Override public void o...
Multicasting is a type of Datagram Socket. Unlike regular Datagrams, Multicasting doesn't handle each client individually instead it sends it out to one IP Address and all subscribed clients will get the message. Example code for a server side: public class Server { private DatagramSo...
To enable or disable a BroadcastReceiver, we need to get a reference to the PackageManager and we need a ComponentName object containing the class of the receiver we want to enable/disable: ComponentName componentName = new ComponentName(context, MyBroadcastReceiver.class); PackageManager packageM...
You can convert a timestamp or interval value to a string with the to_char() function: SELECT to_char('2016-08-12 16:40:32'::timestamp, 'DD Mon YYYY HH:MI:SSPM'); This statement will produce the string "12 Aug 2016 04:40:32PM". The formatting string can be modified in many different wa...
To get Array from any object, use Kernel#Array. The following is an example: Array('something') #=> ["something"] Array([2, 1, 5]) #=> [2, 1, 5] Array(1) #=> [1] Array(2..4) #=> [2, 3, 4] Array([]) #=> [] Array(nil) #=> [] For...
Use tuples in a switch let switchTuple = (firstCase: true, secondCase: false) switch switchTuple { case (true, false): // do something case (true, true): // do something case (false, true): // do something case (false, false): // do something } Or in combina...
Basic assembly support with gcc has the following syntax: asm [ volatile ] ( AssemblerInstructions ) where AssemblerInstructions is the direct assembly code for the given processor. The volatile keyword is optional and has no effect as gcc does not optimize code within a basic asm statement. A...
Example below shows how to create a BroadcastReceiver which is able to receive BOOT_COMPLETED events. This way, you are able to start a Service or start an Activity as soon device was powered up. Also, you can use BOOT_COMPLETED events to restore your alarms since they are destroyed when device is ...
Casting: The Basics Casting is used to transform data from long to wide format. Starting with a long data set: DT = data.table(ID = rep(letters[1:3],3), Age = rep(20:22,3), Test = rep(c("OB_A","OB_B","OB_C"), each = 3), Result = 1:9) We can cast our data using the...
Build yourself three servers using whatever physical or virtual hardware you wish. (This tutorial assumes you're using Ubuntu as your operating system.) Then repeat the following instructions three times... once for each server. # add the names of each server to the host file of each server sudo n...
Then go into the mongo shell and initiate the replica set, like so: meteor mongo > rs.initiate() PRIMARY> rs.add("mongo-a") PRIMARY> rs.add("mongo-b") PRIMARY> rs.add("mongo-c") PRIMARY> rs.setReadPref('secondaryPreferred')
in this way '0' representing the known values ​​are ranked first, '1' representing the NULL values ​​are sorted by the last: SELECT ID ,REGION ,CITY ,DEPARTMENT ,EMPLOYEES_NUMBER FROM DEPT ORDER BY CASE WHEN REGION IS NULL THEN 1 ELSE 0 END, REGION ...
These Java issues can be very embarrassing, and sometimes remain undiscovered until run in production. Fallthrough behavior in switch statements is often useful; however, missing a “break” keyword when such behavior is not desired can lead to disastrous results. If you have forgotten to put a “break...
AsyncTaskLoader is an abstract Loader that provides an AsyncTask to do the work. Here some basic implementation: final class BasicLoader extends AsyncTaskLoader<String> { public BasicLoader(Context context) { super(context); } @Override public String loadInBa...
It is not possible to directly use static_cast, const_cast, dynamic_cast and reinterpret_cast on std::shared_ptr to retrieve a pointer sharing ownership with the pointer being passed as argument. Instead, the functions std::static_pointer_cast, std::const_pointer_cast, std::dynamic_pointer_cast and ...

Page 7 of 14