The yield keyword allows lazy-evaluation of the collection. Forcibly loading the whole collection into memory is called eager evaluation.
The following code shows this:
IEnumerable<int> myMethod()
{
for(int i=0; i <= 8675309; i++)
{
yield return i;
}
}
...
// ...
Consider using Extension Methods as Functions which wrap other code, here's a great example that uses both a static method and and extension method to wrap the Try Catch construct. Make your code Bullet Proof...
using System;
using System.Diagnostics;
namespace Samples
{
/// <summary&g...
Many database configurations require authentication (in the form of a username and password) before you can query the database. You can supply these using the username and password attributes.
Note: the username and password can also be configured against the datasource in the ColdFusion Administra...
A cached query is a query that has its results stored in the server's memory. The results are stored when the query is first run. From then on, whenever that query is requested again, ColdFusion will retrieve the results from memory.
You can cache a query using the cachedAfter attribute. If the que...
You can limit the number of rows to be returned by using the maxrows attribute.
<cfquery datasource="Entertainment" maxrows="50">
select *
from Movies
</cfquery>
You can set a timeout limit using the timeout attribute. This can be useful in preventing requests running far longer than they should and impacting on the whole application as a result.
The timeout attribute sets the maximum number of seconds that each action of a query is allowed to execute befor...
In order to get information about the URI the user agent used to access your resource, you can use the @Context parameter annotation with a UriInfo parameter. The UriInfo object has a few methods that can be used to get different parts of the URI.
//server is running on https://localhost:8080,
// ...
Virtual Methods are methods in Java that are non-static and without the keyword Final in front. All methods by default are virtual in Java. Virtual Methods play important roles in Polymorphism because children classes in Java can override their parent classes' methods if the function being overriden...
Structures in Rust are defined using the struct keyword. The most common form of structure consists of a set of named fields:
struct Foo {
my_bool: bool,
my_num: isize,
my_string: String,
}
The above declares a struct with three fields: my_bool, my_num, and my_string, of the type...
To declare methods on a struct (i.e., functions that can be called "on" the struct, or values of that struct type), create an impl block:
impl Foo {
fn fiddle(&self) {
// "self" refers to the value this method is being called on
println!("fiddling...
Structures can be made generic over one or more type parameters. These types are given enclosed in <> when referring to the type:
struct Gen<T> {
x: T,
z: isize,
}
// ...
let _: Gen<bool> = Gen{x: true, z: 1};
let _: Gen<isize> = Gen{x: 42, z: 2};
let _: Gen...
C.I.A.s are intended as a simple way of getting attributes from whatever is calling the targeted method. There is really only 1 way to use them and there are only 3 attributes.
Example:
//This is the "calling method": the method that is calling the target method
public void doProcess()
...
using System.ComponentModel.DataAnnotations;
public class Post
{
public int Id { get; set; }
[StringLength(100)]
public string Title { get; set;}
[StringLength(300)]
public string Abstract { get; set; }
public string Description { get; set; }
}
Def...
Example showing how to create Guis using functions instead of labels.
Gui, Add, Button, gCtrlEvent vButton1, Button 1
Gui, Add, Button, gCtrlEvent vButton2, Button 2
Gui, Add, Button, gGoButton, Go Button
Gui, Add, Edit, vEditField, Example text
Gui, Show,, Functions instead of labels
CtrlEv...
In Haskell, all functions are considered curried: that is, all functions in Haskell take just one argument.
Let's take the function div:
div :: Int -> Int -> Int
If we call this function with 6 and 2 we unsurprisingly get 3:
Prelude> div 6 2
3
However, this doesn't quite behave in...
If you make a commit as the wrong author, you can change it, and then amend
git config user.name "Full Name"
git config user.email "[email protected]"
git commit --amend --reset-author
[TimeStamp] attribute can be applied to only one byte array property in a given Entity class. Entity Framework will create a non-nullable timestamp column in the database table for that property. Entity Framework will automatically use this TimeStamp column in concurrency check.
using System.Compon...
Function scope is the special scope for labels. This is due to their unusual property. A label is visible through the entire function it is defined and one can jump (using instruction gotolabel) to it from any point in the same function. While not useful, the following example illustrate the point:
...
Caffe can run on multiple cores. One way is to enable multithreading with Caffe to use OpenBLAS instead of the default ATLAS. To do so, you can follow these three steps:
sudo apt-get install -y libopenblas-dev
Before compiling Caffe, edit Makefile.config, replace BLAS := atlas by BLAS := open
A...