Tutorial by Examples: e

We can also use macros for making code easier to read and write. For example we can implement macros for implementing the foreach construct in C for some data structures like singly- and doubly-linked lists, queues, etc. Here is a small example. #include <stdio.h> #include <stdlib.h>...
def arg = [phrase: 'interpolated'] assert "This is $arg.phrase" == 'This is interpolated'
def str = 'old' def interpolated = "I am the ${str} value" assert interpolated == 'I am the old value' str = 'new' assert interpolated == 'I am the old value'
We can have lazy interpolation in Strings. This is different than normal interpolation as the GString can potentially have different values, depending on the closure, whenever it is converted into a String. def str = 'old' def interpolated = "I am the ${ -> str} value" assert interpo...
def str = 'dsl' def interpolated = "Groovy ${str.length() + 1} easy ${str.toUpperCase()}" assert interpolated == 'Groovy 4 easy DSL' str = 'Domain specific language' assert interpolated == 'Groovy 4 easy DSL'
<style name="AppTheme" parent="Theme.AppCompat"> <item name="android:colorEdgeEffect">@color/my_color</item> </style>
5.0 The ripple animation is shown when user presses clickable views. You can use the same ripple color used by your app assigning the ?android:colorControlHighlight in your views. You can customize this color by changing the android:colorControlHighlight attribute in your theme: This effect colo...
The navigation bar (at the bottom of the screen) can be transparent. Here is the way to achieve it. <style name="AppTheme" parent="Theme.AppCompat"> <item name="android:windowTranslucentNavigation">true</item> </style> The Status Bar (t...
Given two types T and U, &T will coerce (implicitly convert) to &U if and only if T implements Deref<Target=U> This allows us to do things like this: fn foo(a: &[i32]) { // code } fn bar(s: &str) { // code } let v = vec![1, 2, 3]; foo(&v); // &Vec&l...
Microbenchmark is useful for estimating the time taking for otherwise fast procedures. For example, consider estimating the time taken to print hello world. system.time(print("hello world")) # [1] "hello world" # user system elapsed # 0 0 0 This i...
As well as being able to create an array by filtering out nil from the transformed elements of a sequence, there is also a version of flatMap(_:) that expects the transformation closure to return a sequence S. extension SequenceType { public func flatMap<S : SequenceType>(transform: (Sel...
You can retrieve the implementation defined name of a type in runtime by using the .name() member function of the std::type_info object returned by typeid. #include <iostream> #include <typeinfo> int main() { int speed = 110; std::cout << typeid(speed).name() <...
A gem is the equivalent to a plugin or an extension for the programming language ruby. To be exact even rails is nothing more than a gem. A lot of gems are built on rails or other gems (they are dependent of said gem) or are standalone. In your Rails project Gemfile For your Rails project you ha...
The easiest way to handle and manage gems is by using bundler. Bundler is a package manager comparable to bower. To use bundler you first need to install it. gem install bundler After you have bundler up and running all you need to do is add gems to your Gemfile and run bundle in your termi...
Here is an example of basic overriding in Python (for the sake of clarity and compatibility with both Python 2 and 3, using new style class and print with ()): class Parent(object): def introduce(self): print("Hello!") def print_name(self): print("Parent...
4.0 Instead of the ForEach-Object cmdlet, the here is also the possibility to use a ForEach method directly on object arrays like so (1..10).ForEach({$_ * $_}) or - if desired - the parentheses around the script block can be omitted (1..10).ForEach{$_ * $_} Both will result in the output ...
Having your scripts call Raycast directly may lead to problems if you need to change the collision matrices in the future, as you'll have to track down every LayerMask field to accommodate the changes. Depending on the size of your project, this may become a huge undertaking. Encapsulating Raycast ...
Lucene is a Java library. If you don't have a Java development environment set up already, see the Java documentation. Download the latest version of Lucene from the Apache website, and unzip it. Add the required jars to your classpath. The following jars will be required by many projects, inclu...
NativeScript’s global console variable lets you print values to your terminal for debugging. The simplest usage is passing a value to the console.log() function: console.log("hello world"); The console object has several other methods, including dump(), trace(), assert() and more. // ...
There are hundreds of settings that can be placed in my.cnf. For the 'lite' user of MySQL, they won't matter as much. Once your database becomes non-trivial, it is advisable to set the following parameters: innodb_buffer_pool_size This should be set to about 70% of available RAM (if you have a...

Page 360 of 1191