60 Matching Annotations
- Jan 2023
-
www.postgresql.org www.postgresql.org
-
The array subscript numbers are written within square brackets. By default PostgreSQL uses a one-based numbering convention for arrays, that is, an array of n elements starts with array[1] and ends with array[n].
-
- Dec 2022
-
-
create_table "project" do |t| t.bigint "employee_ids", array: true t.string "title" end
-
-
-
add_column :videos, :tag_ids, :bigint, array: true Tag.has_many :videos, array: true
-
- Sep 2022
-
www.postgresql.org www.postgresql.org
-
An array of size 1 is considered equal to its sole element.
Tags
Annotators
URL
-
- Mar 2022
-
unix.stackexchange.com unix.stackexchange.com
-
Just let it expand inside an array declaration's right side: list=(../smth*/) # grab the list echo "${#list[@]}" # print array length echo "${list[@]}" # print array elements for file in "${list[@]}"; do echo "$file"; done # loop over the array
-
-
stackoverflow.com stackoverflow.com
-
The short answer is that you want an array: dirs=(/content/{dev01,dev01})
-
-
dba.stackexchange.com dba.stackexchange.com
-
ARRAY( SELECT DISTINCT ... FROM unnest(arr) )
-
- Dec 2021
-
stackoverflow.com stackoverflow.com
-
declaration accepts: | null | [] | [null] | [{foo: 'BAR'}] ------------------------------------------------------------------------ [Vote!]! | no | yes | no | yes [Vote]! | no | yes | yes | yes [Vote!] | yes | yes | no | yes [Vote] | yes | yes | yes | yes
-
-
stackoverflow.com stackoverflow.com
-
function intersperse<T>(this: T[], mkT: (ix: number) => T): T[] { return this.reduce((acc: T[], d, ix) => [...acc, mkT(ix), d], []).slice(1); }
-
- Sep 2021
-
stackoverflow.com stackoverflow.com
-
Array.from(Array(10).keys()) //=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-
-
- Jun 2021
-
stackoverflow.com stackoverflow.com
-
I don't think this warrants adding to the Array class, since it's not generalizable to all the types that Arrays can contain.
You could say the same thing about
Array#sort
. It can cause an error if elements of the array aren't all of the same type/shape. Just make sure it's safe to use first, and thenArray#sort
,Array#sum
,Array#average
, ... are all quite handy and useful to have on Array class. -
instance_eval { reduce(:+) / size.to_f }
-
-
www.postgresql.org www.postgresql.org
-
unnest ( anyarray ) → setof anyelement Expands an array into a set of rows. The array's elements are read out in storage order.
-
-
dba.stackexchange.com dba.stackexchange.com
- Mar 2021
-
github.com github.com
-
The overridden core classes for Hash and Array here only handle those two types. A hash hands off a bury to an Array if it encounter a nested array. Similarly, an Array hands off a bury if it encounters a non-integer or a nested hash.
-
-
stackoverflow.com stackoverflow.com
-
An array is from a logical point of view not an object - although JavaScript handles and reports them as such. In practice however, it is not helpful to see them equal, because they are not.
-
Arrays are definitely objects. Not sure why you think objects can't have a length property nor methods like push, Object.create(Array.prototype) is a trivial counterexample of a non-array object which has these. What makes arrays special is that they are exotic objects with a custom [[DefineOwnProperty]] essential internal method, but they are still objects.
-
- Feb 2021
-
github.com github.com
-
For now I've worked around this by putting all the key-value pairs into an array before passing them into the interaction, then re-building the hash inside the interaction. It works, but it requires some extra code
-
-
github.com github.com
-
array :translations do hash do string :locale string :name end end array inputs can only have one input nested underneath them. This is because every element of the array must be the same type. And the inputs nested inside arrays cannot have names because they would never be used.
-
- Jan 2021
-
developer.mozilla.org developer.mozilla.org
-
While it is easy to imagine that all iterators could be expressed as arrays, this is not true. Arrays must be allocated in their entirety, but iterators are consumed only as necessary. Because of this, iterators can express sequences of unlimited size, such as the range of integers between 0 and Infinity.
-
- Oct 2020
-
stackoverflow.com stackoverflow.com
-
However, this will only walk the object shallowly. To do it deeply, you can use recursion:
-
Note that if you're willing to use a library like lodash/underscore.js, you can use _.pick instead. However, you will still need to use recursion to filter deeply, since neither library provides a deep filter function.
-
-
codesandbox.io codesandbox.io
-
svelte.dev svelte.dev
-
Note that interacting with these <input> elements will mutate the array. If you prefer to work with immutable data, you should avoid these bindings and use event handlers instead.
-
-
codesandbox.io codesandbox.io
-
This demonstrates how FieldArray re-renders (field subscription fires) even when changing unrelated field. Wat?
-
- Sep 2020
-
codesandbox.io codesandbox.io
-
Although, meta.valid works, meta.active, meta.dirty, meta.touched, meta.visited never change from false.
See also: https://github.com/final-form/react-final-form-arrays/issues/147
-
-
codesandbox.io codesandbox.io
-
medium.com medium.com
-
stackoverflow.com stackoverflow.com
-
function* enumerate(iterable) { let i = 0; for (const x of iterable) { yield [i, x]; i++; } } for (const [i, obj] of enumerate(myArray)) { console.log(i, obj); }
-
for (let [index, val] of array.entries())
-
Note that Array.entries() returns an iterator, which is what allows it to work in the for-of loop; don't confuse this with Object.entries(), which returns an array of key-value pairs.
-
- Aug 2020
-
stackoverflow.com stackoverflow.com
-
Note that the double quotes around "${arr[@]}" are really important. Without them, the for loop will break up the array by substrings separated by any spaces within the strings instead of by whole string elements within the array. ie: if you had declare -a arr=("element 1" "element 2" "element 3"), then for i in ${arr[@]} would mistakenly iterate 6 times since each string becomes 2 substrings separated by the space in the string, whereas for i in "${arr[@]}" would iterate 3 times, correctly, as desired, maintaining each string as a single unit despite having a space in it.
-
- Jul 2020
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
stackoverflow.com stackoverflow.com
-
require 'set' class Array def uniq_elements(&prc) prc ||= ->(e) { e } uniques, dups = {}, Set.new each do |e| k = prc[e] ((uniques.key?(k)) ? (dups << k; uniques.delete(k)) : uniques[k] = e) unless dups.include?(k) end uniques.values end end
-
-
twitter.com twitter.com
-
To me the difference between [1,1,2,2,3,3] and [1,2,3] is not []
-
It’s even worse that there’s no alternative method that does the unsurprising thing IMO.
-
-
github.com github.com
-
One may expect Array#- to behave like mathematical subtraction or difference when it doesn't. One could be forgiven to expect the following behavior: [1,1,2,2,3,3,4,4] - [1,2,3,4] => [1,2,3,4]
-
I'll freely admit I was surprised by this behavior myself since I needed to obtain an Array with only one instance of each item in the argument array removed.
-
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
Arrays are not sets. Trying to treat them as if they are is an error, and will create subtle problems. What should be the result of the following operations? [1, 1] | [1] [1] | [1, 1] Of course, there are more interesting examples. These two are to get you started. I don't care what the results currently are. I don't care what you think they should be. I can present extremely strong arguments for various answers. For this reason, I believe that #| is an ill-defined concept. Generalizing an ill-defined concept is a world of pain. If you insist on treating objects of one class as if they were members of a different class, there should be bumps in the road to at least warn you that maybe this is a bad idea. I'm not going to argue that we should remove or deprecate #|. I don't think of myself as a fanatic. But encouraging this sort of abuse of the type system just creates problems.
-
-
github.com github.com
-
-
So why isn't there an easy way to remove an element from such an array in a way that respects both the order and number (count) of each element? Why do all methods for removing elements from an array assume that you always want to remove all matching elements from the receiver, with no option to do otherwise?
Tags
Annotators
URL
-
-
Tags
Annotators
URL
-
- May 2020
-
stackoverflow.com stackoverflow.com
-
In PostrgreSQL 8.4 and up you can use: select array_agg(x) from (select unnest(ARRAY[1,5,3,7,2]) AS x order by x) as _; But it will not be very fast.
-
The best way to sort an array of integers is without a doubt to use the intarray extension, which will do it much, much, much faster than any SQL formulation: CREATE EXTENSION intarray; SELECT sort( ARRAY[4,3,2,1] );
-
-
www.postgresql.org www.postgresql.org
-
It is also possible to construct an array from the results of a subquery. In this form, the array constructor is written with the key word ARRAY followed by a parenthesized (not bracketed) subquery.
-
An array constructor is an expression that builds an array value using values for its member elements. A simple array constructor consists of the key word ARRAY, a left square bracket [, a list of expressions (separated by commas) for the array element values, and finally a right square bracket ].
-
-
dba.stackexchange.com dba.stackexchange.com
-
Sure, with json_object_keys(). This returns a set - unlike the JavaScript function Object.keys(obj) you are referring to, which returns an array. Feed the set to an ARRAY constructor to transform it: SELECT id, ARRAY(SELECT json_object_keys(obj)) AS keys FROM tbl_items;
-
- Sep 2019
- Aug 2019
-
codesandbox.io codesandbox.io
-
codesandbox.io codesandbox.io