Traditional way
interface MathOperation{
boolean unaryOperation(int num);
}
public class LambdaTry {
public static void main(String[] args) {
MathOperation isEven = new MathOperation() {
@Override
public boolean unaryOperation(int num) {
...
A class can have non-static member functions, which operate on individual instances of the class.
class CL {
public:
void member_function() {}
};
These functions are called on an instance of the class, like so:
CL instance;
instance.member_function();
They can be defined either ins...
A simple EntitySystem that processes each entity of a given family in the order specified by a comparator and calls processEntity() for each entity every time the EntitySystem is updated. This is really just a convenience class as rendering systems tend to iterate over a list of entities in a sort...
One can verify whether a method was called on a mock by using Mockito.verify().
Original mock = Mockito.mock(Original.class);
String param1 = "Expected param value";
int param2 = 100; // Expected param value
//Do something with mock
//Verify if mock was used properly
Mockito.veri...
Our first element directive will not do much: it will just calculate 2+2 and will be called in html like this:
<my-calculator></my-calculator>
Notice the name of the directive is myCalculator (in CamelCase), but in html it's used as my-calculator (in lisp-case).
Since we want our di...
Factory Method is one of creational design patterns. It is used to deal with the problem of creating objects without specifying exact result type. This document will teach you how to use Factory Method DP properly.
Let me explain the idea of it to you on a simple example. Imagine you're working in ...
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...
The DatePicker class has a property, SelectedDate, which enable you to get or set the selected date. If there is none selected, it means its value will be null.
if (datePicker.SelectedDate == null)
{
// Do what you have to do
}
Android developers(mainly beginners) have been confused regarding Internal & External storage terminology. There are lot of questions on Stackoverflow regarding the same. This is mainly because of the fact that terminology according to Google/official Android documentation is quite different to...
iOS 6
Within a single line, we can get an UUID like below:
Swift
let UDIDString = UIDevice.currentDevice().identifierForVendor?.UUIDString
Objective-C
NSString *UDIDString = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
The identifierForVendor is an unique identifier that st...
var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("test");
var collection = database.GetCollection < Interactions > ("Interactions");
var newItem = new Interactions{
SiteName = "Example",
Pages = ...
var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("test");
var collection = database.GetCollection < Interactions > ("Interactions");
var result = IMongoCollectionExtensions
.AsQueryable(collection)
...
First let's create an ExchangeManager object, where the constructor will connect to the services for us. It also has a GetOofSettings method, which will return the OofSettings object for the specified email address :
using System;
using System.Web.Configuration;
using Microsoft.Exchange.WebServic...