Swift
Ctrl + Drag from the UItextfield in MainStoryboard to the ViewController Class and create a UITextField Outlet
After that select the UItextField again and Ctrl+drag in ViewController class but this time select Action connection and on storage select Did End On Exit then click connect.
...
As Rails follows the MVC pattern Views are where your "templates" are for your actions.
Let's say you have a controller articles_controller.rb. For this controller you would have a folder in views called app/views/articles:
app
|-- controllers
| '-- articles_controller.rb
|
'-- vie...
You can use an initializer to set default property values:
struct Example {
var upvotes: Int
init() {
upvotes = 42
}
}
let myExample = Example() // call the initializer
print(myExample.upvotes) // prints: 42
Or, specify default property values as a part of the property...
The Number constructor has some built in constants that can be useful
Number.MAX_VALUE; // 1.7976931348623157e+308
Number.MAX_SAFE_INTEGER; // 9007199254740991
Number.MIN_VALUE; // 5e-324
Number.MIN_SAFE_INTEGER; // -9007199254740991
Number.EPSILON; // 0.000...
This is a minimalist module that only slurps files into variables, nothing else.
use File::Slurper 'read_text';
my $contents = read_text($filename);
read_text() takes two optional parameters to specify the file encoding and whether line endings should be translated between the unixish LF or DOS...
Don't use it. Although it has been around for a long time and is still the module most programmers will suggest, it is broken and not likely to be fixed.
With the use of the extends keyword among classes, all the properties of the superclass (also known as the Parent Class or Base Class) are present in the subclass (also known as the Child Class or Derived Class)
public class BaseClass {
public void baseMethod(){
System.out.println(&...
A generic class with the type parameter Type
class MyGenericClass<Type>{
var value: Type
init(value: Type){
self.value = value
}
func getValue() -> Type{
return self.value
}
func setValue(value: Type){
self.value = value
}...
Running
$ pip install --upgrade SomePackage
will upgrade package SomePackage and all its dependencies. Also, pip automatically removes older version of the package before upgrade.
To upgrade pip itself, do
$ pip install --upgrade pip
on Unix or
$ python -m pip install --upgrade pip
on ...
Euler angles are "degree angles" like 90, 180, 45, 30 degrees. Quaternions differ from Euler angles in that they represent a point on a Unit Sphere (the radius is 1 unit). You can think of this sphere as a 3D version of the Unit circle you learn in trigonometry.
Quaternions differ from Eu...
Quaternion.LookRotation(Vector3 forward [, Vector3 up]) will create a Quaternion rotation that looks forward 'down' the forward vector and has the Y axis aligned with the 'up' vector. If the up vector is not specified, Vector3.up will be used.
Rotate this Game Object to look at a target Game Object...
Examine the following strings:
foobarfoo
bar
foobar
barfoo
the regular expression bar will match all four strings,
\bbar\b will only match the 2nd,
bar\b will be able to match the 2nd and 3rd strings, and
\bbar will match the 2nd and 4th strings.
virtual and override
The virtual keyword allows a method, property, indexer or event to be overridden by derived classes and present polymorphic behavior. (Members are non-virtual by default in C#)
public class BaseClass
{
public virtual void Foo()
{
Console.WriteLine("Foo...
A recursive function is simply a function, that would call itself.
function factorial (n) {
if (n <= 1) {
return 1;
}
return n * factorial(n - 1);
}
The above function shows a basic example of how to perform a recursive function to return a factorial.
Another...
First of all, we need to add our first Fragment at the beginning, we should do it in the onCreate() method of our Activity:
if (null == savedInstanceState) {
getSupportFragmentManager().beginTransaction()
.addToBackStack("fragmentA")
.replace(R.id.container, FragmentA.n...
So let's suppose you want to iterate only between some specific lines of a file
You can make use of itertools for that
import itertools
with open('myfile.txt', 'r') as f:
for line in itertools.islice(f, 12, 30):
# do something here
This will read through the lines 13 to 20 as i...