set alpha {a 1 b 2 c 3}
dict get $alpha b
# => 2
dict get $alpha d
# (ERROR) key "d" not known in dictionary
If dict get is used to retrieve the value of a missing key, an error is raised. To prevent the error, use dict exists:
if {[dict exists $alpha $key]} {
set result [d...
// A simple class hierarchy that uses the visitor to add functionality.
//
class VehicleVisitor;
class Vehicle
{
public:
// To implement the visitor pattern
// The class simply needs to implement the accept method
// That takes a reference to a visitor object tha...
You can disable compiler warnings using #pragma warning disable and restore them using #pragma warning restore:
#pragma warning disable CS0168
// Will not generate the "unused variable" compiler warning since it was disabled
var x = 5;
#pragma warning restore CS0168
// Will gene...
Here is an example:
my_array = array('i', [1,2,3,4,5])
c=[11,12,13]
my_array.fromlist(c)
# array('i', [1, 2, 3, 4, 5, 11, 12, 13])
So we see that the values 11,12 and 13 were added from list c to my_array.
When you need a Python list object, you can utilize the tolist() method to convert your array to a list.
my_array = array('i', [1,2,3,4,5])
c = my_array.tolist()
# [1, 2, 3, 4, 5]
An alert box can be popped-up on a Xamarin.Forms Page by the method, DisplayAlert. We can provide a Title, Body (Text to be alerted) and one/two Action Buttons. Page offers two overrides of DisplayAlert method.
public Task DisplayAlert (String title, String message, String cancel)
This overri...
After the subscription was created, it is important to manage its correct deallocation.
The docs told us that
If a sequence terminates in finite time, not calling dispose or not using addDisposableTo(disposeBag) won't cause any permanent resource leaks. However, those resources will be used unti...
In some places in Common Lisp, a series of forms are evaluated in order. For instance, in the body of a defun or lambda, or the body of a dotimes. In those cases, writing multiple forms in order works as expected. In a few places, however, such as the then and else parts of an if expressions, onl...
Node Version Manager (nvm) greatly simplifies the management of Node.js versions, their installation, and removes the need for sudo when dealing with packages (e.g. npm install ...). Fish Shell (fish) "is a smart and user-friendly command line
shell for OS X, Linux, and the rest of the family&...
OpenCL is short for Open Computing Language. OpenCL is a Framework for parallel programming across heterogeneous platforms, called compute devices, ranging from CPUs over GPUs to more special platforms like FPGAs. OpenCL provides a standard interface for parallel computing on these compute devices b...
If you have a modern CPU or graphics card (GPU) inside your machine, chances are you have everything ready for first steps in OpenCL.
Finding out if your processor is OpenCL capable can be usually done via the manufacturer's homepage, a good first start is the official documentation at
https://www...
Principal Component Analysis finds sequences of linear combinations of the features. The first linear combination maximizes the variance of the features (subject to a unit constraint). Each of the following linear combinations maximizes the variance of the features in the subspace orthogonal to that...
You can check if a variable has been defined in a scope by using ColdFusion's built in StructKeyExists() function. This can be used inside a <cfif> tag to prevent error messages in the event you attempt to refer to a variable that does not exist. You can also use this function to determine whe...
You can, of course, return lists from subs:
sub foo {
my @list1 = ( 1, 2, 3 );
my @list2 = ( 4, 5 );
return ( @list1, @list2 );
}
my @list = foo();
print @list; # 12345
But it is not the recommended way to do that unless you know what you are doing.
While th...
Lets use the same code as above for this example.
#include <iostream>
void fail() {
int *p1;
int *p2(NULL);
int *p3 = p1;
if (p3) {
std::cout << *p2 << std::endl;
}
}
int main() {
fail();
}
First lets compile it
g++ -g -o main m...
A function template can be overloaded under the rules for non-template function overloading (same name, but different parameter types) and in addition to that, the overloading is valid if
The return type is different, or
The template parameter list is different, except for the naming of paramete...
Writing and managing ADO.Net code for data access is a tedious and monotonous job. Microsoft has provided an O/RM framework called "Entity Framework" to automate database related activities for your application.
Entity framework is an Object/Relational Mapping (O/RM) framework. It is an e...
CoffeeScript's existential operator ? check if the variable is null or undefined.
1. Check for null or undefined.
alert "Hello CoffeeScript!" if myVar?
javascript equivalent:
if (typeof myVar !== "undefined" && myVar !== null) {
alert("Hello CoffeeScript!&qu...