Tutorial by Examples: al

The default value for an enum is zero. If an enum does not define an item with a value of zero, its default value will be zero. public class Program { enum EnumExample { one = 1, two = 2 } public void Main() { var e =...
def my_mix(name,valid=true, *opt) puts name puts valid puts opt end Call as follows: my_mix('me') # 'me' # true # [] my_mix('me', false) # 'me' # false # [] my_mix('me', true, 5, 7) # 'me' # true # [5,7]
Browsers have a default set of CSS styles they use for rendering elements. Some of these styles can even be customised using the browser's settings to change default font face and size definitions, for example. The styles contain the definition of which elements are supposed to be block-level or inl...
You can initialize a constant by using the const keyword. const foo = 100; const bar = false; const person = { name: "John" }; const fun = function () = { /* ... */ }; const arrowFun = () => /* ... */ ; Important You must declare and initialize a constant in the same statement....
Python supports using a for loop directly on a list: my_list = ['foo', 'bar', 'baz'] for item in my_list: print(item) # Output: foo # Output: bar # Output: baz You can also get the position of each item at the same time: for (index, item) in enumerate(my_list): print('The item i...
GitHub is a huge collection of Git repositories. In other words, you can think of GitHub as a collection of many projects! Creating An Account Visit GitHub's main page Here Pick a username, enter in your email address, and pick a secure password and you're ready to go! Useful Tools For Git/...
Assuming you have a model called Post defined in your models.py file that contains blog posts, and has a date_published field. Step 1: Write the context processor Create (or add to) a file in your app directory called context_processors.py: from myapp.models import Post def recent_blog_posts...
While the math.sqrt function is provided for the specific case of square roots, it's often convenient to use the exponentiation operator (**) with fractional exponents to perform nth-root operations, like cube roots. The inverse of an exponentiation is exponentiation by the exponent's reciprocal. S...
Literal format strings were introduced in PEP 498 (Python3.6 and upwards), allowing you to prepend f to the beginning of a string literal to effectively apply .format to it with all variables in the current scope. >>> foo = 'bar' >>> f'Foo is {foo}' 'Foo is bar' This works wi...
Detailed instructions on getting couchbase set up or installed.
Getting the Constructor Object You can obtain Constructor class from the Class object like this: Class myClass = ... // get a class object Constructor[] constructors = myClass.getConstructors(); Where the constructors variable will have one Constructor instance for each public constructor decl...
To demystify Template Haskell, suppose you have data Example a = Example { _foo :: Int, _bar :: a } then makeLenses 'Example produces (more or less) foo :: Lens' (Example a) Int bar :: Lens (Example a) (Example b) a b There's nothing particularly magical going on, though. You can write ...
A Traversal' s a shows that s has 0-to-many as inside of it. toListOf :: Traversal' s a -> (s -> [a]) Any type t which is Traversable automatically has that traverse :: Traversal (t a) a. We can use a Traversal to set or map over all of these a values > set traverse 1 [1..10] [1,1,1,...
You can use Optional Chaining in order to call a method, access a property or subscript an optional. This is done by placing a ? between the given optional variable and the given member (method, property or subscript). struct Foo { func doSomething() { print("Hello World!") ...
Here is a simple model that we will use to run a few test queries: class MyModel(models.Model): name = models.CharField(max_length=10) model_num = models.IntegerField() flag = models.NullBooleanField(default=False) Get a single model object where the id/pk is 4: (If there are no...
Using Playground it is easy to see that happens inside loops or objects while the change is happening. For example, in the code below, the value of x will change from 1 to 4. import UIKit for x in [1, 2, 3, 4] { x } (1) Clicking on the eye symbol on the right will give us a quick look. (2...
function themeSlug_enqueue_scripts() { wp_enqueue_style( 'themeSlug-reset', get_template_directory_uri() .'/css/reset.css', '1.0.0' ); wp_enqueue_style( 'themeSlug-style', get_template_directory_uri() .'/style.css', 'themeSlug-reset', '1.0.0'); } add_action('wp_enqueue_scripts', 'themeSl...
In this case style.css is located in root of the theme's folder function themeSlug_enqueue_scripts() { wp_enqueue_style( 'themeSlug-style', get_template_directory_uri() .'/style.css', '1.0.0'); } add_action('wp_enqueue_scripts', 'themeSlug_enqueue_scripts');
In this example we want to include font awesome icon font function themeSlug_enqueue_scripts() { wp_enqueue_style( 'font-awesome', '//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css'); } add_action('wp_enqueue_scripts', 'themeSlug_enqueue_scripts');
Functions are only useful if we can call them. To call a function the following syntax is used: print("Hello, World!") We're calling the print function. Using the argument "Hello, World". As is obvious, this will print Hello, World to the output stream. The returned value is ...

Page 32 of 269