Tutorial by Examples: element

<Foo> <Dog/> </Foo> public class Foo { // Using XmlElement [XmlElement(Name="Dog")] public Animal Cat { get; set; } }
var names = new[] {"Foo","Bar","Fizz","Buzz"}; var thirdName = names.ElementAt(2); Console.WriteLine(thirdName); //Fizz //The following throws ArgumentOutOfRangeException var minusOnethName = names.ElementAt(-1); var fifthName = names.ElementAt(4); ...
var names = new[] {"Foo","Bar","Fizz","Buzz"}; var thirdName = names.ElementAtOrDefault(2); Console.WriteLine(thirdName); //Fizz var minusOnethName = names.ElementAtOrDefault(-1); Console.WriteLine(minusOnethName); //null var fifthName = names.Eleme...
Select allows you to apply a transformation to every element in any data structure implementing IEnumerable. Getting the first character of each string in the following list: List<String> trees = new List<String>{ "Oak", "Birch", "Beech", "Elm", ...
Collect with toList() and toSet() Elements from a Stream can be easily collected into a container by using the Stream.collect operation: System.out.println(Arrays .asList("apple", "banana", "pear", "kiwi", "orange") .stream() .filter...
Addition Map<Integer, String> map = new HashMap<>(); map.put(1, "First element."); System.out.println(map.get(1)); Output: First element. Override Map<Integer, String> map = new HashMap<>(); map.put(1, "First element."); map.put(1, &quot...
The <article> element contains self-contained content like articles, blog posts, user comments or an interactive widget that could be distributed outside the context of the page, for example by RSS. When article elements are nested, the contents of the inner article node should be related t...
The <main> element contains the main content for your web page. This content is unique to the individual page, and should not appear elsewhere on the site. Repeating content like headers, footers, navigation, logos, etc., is placed outside the element. The <main> element should only e...
The <nav> element is primarily intended to be used for sections that contain main navigation blocks for the website, this can include links to other parts of the web page (e.g. anchors for a table of contents) or other pages entirely. Inline items The following will display an inline set of ...
# First falsy element or last element if all are truthy: reduce(lambda i, j: i and j, [100, [], 20, 10]) # = [] reduce(lambda i, j: i and j, [100, 50, 20, 10]) # = 10 # First truthy element or last element if all falsy: reduce(lambda i, j: i or j, [100, [], 20, 0]) # = 100 reduce(la...
All built-in collections in Python implement a way to check element membership using in. List alist = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 5 in alist # True 10 in alist # False Tuple atuple = ('0', '1', '2', '3', '4') 4 in atuple # False '4' in atuple # True String astring = 'i am a s...
Defines an <initially-hidden> custom element which hides its contents until a specified number of seconds have elapsed. const InitiallyHiddenElement = document.registerElement('initially-hidden', class extends HTMLElement { createdCallback() { this.revealTimeoutId = null; } at...
It's possible to extent native elements, but their descendants don't get to have their own tag names. Instead, the is attribute is used to specify which subclass an element is supposed to use. For example, here's an extension of the <img> element which logs a message to the console when it's l...
Print element at index 0 echo "${array[0]}" 4.3 Print last element using substring expansion syntax echo "${arr[@]: -1 }" 4.3 Print last element using subscript syntax echo "${array[-1]}" Print all elements, each quoted separately echo "${array[@...
Import the ElementTree object, open the relevant .xml file and get the root tag: import xml.etree.ElementTree as ET tree = ET.parse("yourXMLfile.xml") root = tree.getroot() There are a few ways to search through the tree. First is by iteration: for child in root: print(child.ta...
Let's say you've got a list of restaurants -- maybe you read it from a file. You care about the unique restaurants in the list. The best way to get the unique elements from a list is to turn it into a set: restaurants = ["McDonald's", "Burger King", "McDonald's", &qu...
To remove an element inside an array, e.g. the element with the index 1. $fruit = array("bananas", "apples", "peaches"); unset($fruit[1]); This will remove the apples from the list, but notice that unset does not change the indexes of the remaining elements. So $fr...
One of the most common tasks is retrieving an existing element from the DOM to manipulate. Most commonly these methods are executed on document, because it is the root node, but all these methods work on any HTML element in the tree. They will only return children from the node it is executed on. R...
An element can be cloned by invoking the cloneNode method on it. If the first parameter passed to cloneNode is true, the children of the original will also be cloned. var original = document.getElementsByTagName("li")[0]; var clone = original.cloneNode(true);
Appending an element at the end of a vector (by copying/moving): struct Point { double x, y; Point(double x, double y) : x(x), y(y) {} }; std::vector<Point> v; Point p(10.0, 2.0); v.push_back(p); // p is copied into the vector. C++11 Appending an element at the end of a vector ...

Page 1 of 15