Tutorial by Examples

You can use Map<String, List<String>> myMap = new HashMap<>(); instead of Map<String, List<String>> myMap = new HashMap<String, List<String>>(); However, you can't use List<String> list = new ArrayList<>(); list.add("A"); ...
public String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) { String typeOfDay; switch (dayOfWeekArg) { case "Monday": typeOfDay = "Start of work week"; break; case "Tuesday": case "Wednes...
Detailed instructions on getting caching set up or installed.
If you are using Windows open Git Bash. If you are using Mac or Linux open your Terminal. Before you generate an SSH key, you can check to see if you have any existing SSH keys. List the contents of your ~/.ssh directory: $ ls -al ~/.ssh # Lists all the files in your ~/.ssh directory Check...
// Takes a callback and executes it with the read value def readFile(path: String)(callback: Try[String] => Unit): Unit = ??? readFile(path) { _.flatMap { file1 => readFile(path2) { _.foreach { file2 => processFiles(file1, file2) }} }} The function argument to readFile is...
If shift is called outside of a delimiting reset block, it can be used to create functions that themselves create continuations inside a reset block. It is important to note that shift's type is not just (((A => B) => C) => A), it is actually (((A => B) => C) => (A @cpsParam[B, C])...
We can have three cases to analyze an algorithm: Worst Case Average Case Best Case #include <stdio.h> // Linearly search x in arr[]. If x is present then return the index, // otherwise return -1 int search(int arr[], int n, int x) { int i; for (i=0; i<n; i...
Not everything in a bindings library will have the same name in C# as it does in Java. In C#, interface names start with "I", but Java has no such convention. When you import a Java library, an interface named SomeInterface will become ISomeInterface. Similarly, Java doesn't have propert...
For simple cases, you can filter data directly. a = np.random.normal(size=10) print(a) #[-1.19423121 1.10481873 0.26332982 -0.53300387 -0.04809928 1.77107775 # 1.16741359 0.17699948 -0.06342169 -1.74213078] b = a[a>0] print(b) #[ 1.10481873 0.26332982 1.77107775 1.16741359 0.176999...
In order to create a workspace, one should run the following in the terminal: $ mkdir -p ~/workspace_name/src $ cd ~/workspace_name/src $ catkin_init_workspace $ cd ~/workspace_name/ $ catkin_make The previous commands creates a workspace named workspace_name. Once a workspace has been creat...
Assuming a workspace named workspace_name has been previously created in the home directory, a package named package_name can be created by executing the following command lines. $ cd ~/workspace_name/src/ $ catkin_create_pkg package_name rospy
The Null literal (written as null) represents the one and only value of the null type. Here are some examples MyClass object = null; MyClass[] objects = new MyClass[]{new MyClass(), null, new MyClass()}; myMethod(null); if (objects != null) { // Do something }...
The if statement is a conditional statement that allows a program to enter or not a specific section of code depending if the condition(s) of the statement are met or not. It can be found in mostly all the existing programming languages. The if statement will usually take the following shape: if(s...
A statement is usually a test on a variable or the return value of a function. To test those values, we can use some relational operators: OperatorMeaningExample==Equal to1 == 1 is TRUE, 1 == 2 is FALSE!=Not equal to1 != 2 is TRUE, 1 != 1 is FALSE<Less than1 < 2 is TRUE, 2 < 1 is FALSE>...
It is possible to ask a program to execute a specific section of code only if an if statement is considered false. For this, we use the else key word. if(statement) { // Code to execute if the statement is true. } else { // Code to execute if the statement is false. } Both code se...
A std::tuple<T...> can be used to pass multiple values around. For example, it could be used to store a sequence of parameters into some form of a queue. When processing such a tuple its elements need to be turned into function call arguments: #include <array> #include <iostream>...
std::integer_sequence itself is about holding a sequence of integers which can be turned into a parameter pack. Its primary value is the possibility to create "factory" class templates creating these sequences: #include <iostream> #include <initializer_list> #include <uti...
Expanding the parameter pack of indices in a comma expression with a value creates a copy of the value for each of the indices. Sadly, gcc and clang think the index has no effect and warn about it (gcc can be silenced by casting the index to void): #include <algorithm> #include <array>...
The phpunit.xml file is the default configuration file for tests and is already setup for testing with PHPUnit. The default testing environment APP_ENV is defined as testing with array being the cache driver CACHE_DRIVER. With this setup, no data (session/cache) will be retained while testing. T...
Declaring the splat is useful for reusing sets of parameters multiple times or with slight variations: $splat = @{ Class = "Win32_SystemEnclosure" Property = "Manufacturer" ErrorAction = "Stop" } Get-WmiObject -ComputerName $env:COMPUTERNAME @splat Get...

Page 1073 of 1336