Tutorial by Examples: blocks

The scope of a variable in a block { ... }, begins after declaration and ends at the end of the block. If there is nested block, the inner block can hide the scope of a variable which is declared in the outer block. { int x = 100; // ^ // Scope of `x` begins here // } // ...
Blocks are chunks of code enclosed between braces {} (usually for single-line blocks) or do..end (used for multi-line blocks). 5.times { puts "Hello world" } # recommended style for single line blocks 5.times do print "Hello " puts "world" end # recomme...
This is our buffer: void write_buffer(size_t size, char ** buffer) { char * buf = *buffer; size_t iter; for(iter = 0; iter < size; iter++) { putc(*(buf + iter)); } } The cursor is at [1][1] ([line][col]). Move the cursor to the curl bracket of the for loop...
returnType (^blockName)(parameterType1, parameterType2, ...) = ^returnType(argument1, argument2, ...) {...}; float (^square)(float) = ^(float x) {return x*x;}; square(5); // resolves to 25 square(-7); // resolves to 49 Here's an example with no return and no parameters: NSMutableDicti...
With implicit keys: key: value another key: - some - more - values [1, 2, 3]: last value, which has a flow style key With implicit and explicit keys: ? key : value another key: - some - more - values ? [1, 2, 3] : last value, which has a flow style key key, another ...
A CSS rule consists of a selector (e.g. h1) and declaration block ({}). h1 {}
Another powerful & mature concurrency tool in Haskell is Software Transactional Memory, which allows for multiple threads to write to a single variable of type TVar a in an atomic manner. TVar a is the main type associated with the STM monad and stands for transactional variable. They're used m...
While you can use the @testSetup annotation to designate a method to be run before tests are executed, this method will usually only be run once. If you need code to be run before each test, you can use a static block: @isTest public class MyTest { static { // code here will be run before ...
display: inline-block; The display property with the value of inline-block is not supported by Internet Explorer 6 and 7. A work-around for this is: zoom: 1; *display: inline; The zoom property triggers the hasLayout feature of elements, and it is available only in Internet Explorer. The *di...
Block strings can be used to hold formatted or indentation-sensitive text (or, if you just don't feel like escaping quotes and apostrophes). The indentation level that begins the block is maintained throughout, so you can keep it all aligned with the body of your code. html = """ ...
You can throw exception in try catch block: DECLARE @msg nvarchar(50) = 'Here is a problem!' BEGIN TRY print 'First statement'; THROW 51000, @msg, 15; print 'Second statement'; END TRY BEGIN CATCH print 'Error: ' + ERROR_MESSAGE(); THROW; END CATCH Exception with be ...
Tests are an excellent way to ensure stable, bug-free applications. They serve as an interactive documentation and allow to modify code without fear to break functionality. D provides a convenient and native syntax for unittest block as part of the D language. Anywhere in a D module unittest blocks ...
To add a code block, surround it with #+BEGIN_SRC language and #+END_SRC. language should correspond to the major mode for the language in question, e.g. the major mode for Emacs Lisp is emacs-lisp-mode, so write #+BEGIN_SRC emacs-lisp. #+BEGIN_SRC emacs-lisp (defun hello-world () (interactive)...
Mage_Core_Block_Template Mage_Core_Block_Text_List Mage_Core_Block_Messages Mage_Core_Block_Text_Tag Mage_Core_Block_Text Mage_Page_Block_Template_Links All blocks are either structural blocks or All blocks are either structural blocks or content blocks. Example: core/text_list Example ...
Parts of template can be displayed conditionally. If statement is used for this purpose. It's similar to if statement in programing languages. Contents of block are executed/displayed if an expression evaluates to true. {% if enabled == false %} Disabled {% endif %} Disabled will be displ...
One of the most useful things that came along with sections is blocks. Blocks are basically a blueprint for something that can be created an unlimited amount of times. One of the best examples is the slides of a slider. A block is a top level item in the schema, meaning it is alongside things like n...
Using with blocks can accelerate the process of running a macro. Instead writing a range, chart name, worksheet, etc. you can use with-blocks like below; With ActiveChart .Parent.Width = 400 .Parent.Height = 145 .Parent.Top = 77.5 + 165 * step - replacer * 15 .Parent.Left = 5 E...
Block Size and Blocks in HDFS : HDFS has the concept of storing data in blocks whenever a file is loaded. Blocks are the physical partitions of data in HDFS ( or in any other filesystem, for that matter ). Whenever a file is loaded onto the HDFS, it is splitted physically (yes, the file is divi...
If you want to comment part of your code, then comment blocks may be useful. Comment block starts with a %{ in a new line and ends with %} in another new line: a = 10; b = 3; %{ c = a*b; d = a-b; %} This allows you fo fold the sections that you commented to make the code more clean and comp...
Download and install Code::Blocks here. If you're on Windows, be careful to select a file for which the name contains mingw, the other files don't install any compiler. Open Code::Blocks and click on "Create a new project": Select "Console application" and click &...

Page 2 of 3