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 class constructor must have the same name as its class.
Let's create a constructor for a class Person:
class Person {
String name;
String gender;
int age;
Person(this.name, this.gender, this.age);
}
The example above is a simpler, better way of defining the constructor than the...
Dart functions may also be declared anonymously or nested.
For example, to create a nested function, just open a new function block within an existing function block
void outerFunction() {
bool innerFunction() {
/// Does stuff
}
}
The function innerFunction may now be us...
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...
Just as you're able to bind data from a view to the model, you can also bind props using the same v-bind directive for passing information from parent to child components.
JS
new Vue({
el: '#example',
data: {
msg: 'hello world'
}
});
Vue.component('child', {
props:...
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...
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 ...
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...
To uninstall Node.js on Windows, use Add or Remove Programs like this:
Open Add or Remove Programs from the start menu.
Search for Node.js.
Windows 10:
Click Node.js.
Click Uninstall.
Click the new Uninstall button.
Windows 7-8.1:
Click the Uninstall button under Node.js.
ALTER TABLE foo ENGINE=InnoDB;
This converts the table, but does not take care of any differences between the engines. Most differences will not matter, especially for small tables. But for busier tables, other considerations should be considered. Conversion considerations
A branch is just a pointer to a commit, so you can freely move it around. To make it so that the branch is referring to the commit aabbcc, issue the command
git reset --hard aabbcc
Please note that this will overwrite your branch's current commit, and as so, its entire history. You might loose s...
Example from the standard library (core.clj:807):
(defmacro and
"Evaluates exprs one at a time, from left to right. If a form
returns logical false (nil or false), and returns that value and
doesn't evaluate any of the other expressions, otherwise it returns
the value of the last e...
section .data
msg db "Hello world!",10 ; 10 is the ASCII code for a new line (LF)
section .text
global _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 13
syscall
mov rax, 60
mov rdi, 0
syscall
If you want to e...