Questions tagged [square-bracket]

The symbols "[" and "]", commonly used in programming languages. Please use this tag only if the specific usage of these symbols is a relevant part of the question.

Overview

The square brackets "[" and "]" are special cases of brackets, along with parentheses and curly brackets (or braces) ("{", "}").

Uses

Square brackets have many uses in most programming languages, such as:

279 questions
5
votes
4 answers

How to determine which exceptions "x[]" might throw?

C# reference for square brackets says: Square brackets [] are used for arrays, indexers, and attributes. They can also be used with pointers. (It also says, for arrays) An exception is thrown if an array index is out of range. So when you're using…
Edward Ned Harvey
  • 6,525
  • 5
  • 36
  • 45
4
votes
2 answers

creating a class that can receive board1[{1,1}]='X'; ? (curly brackets inside square brackets)

I got H.W. that in one of the lines of the main.cpp I am suppose to support: board1[{1,1}]='X'; the logical meaning behind this is to assign to a "game board" the char 'X' at the position of (1,1). I have no clue how to create an array that…
Tomer
  • 531
  • 7
  • 19
4
votes
2 answers

Usage of square brackets in MATLAB

In MATLAB you can create an array of integers easily with N = 100; % Number of points A = 1:N; % row vector of 1,2,3,..., 100 If I want a column vector instead of a row vector, I can do that with A = [1:N].'; Now, MATLAB warns me that Use of…
Adriaan
  • 17,741
  • 7
  • 42
  • 75
4
votes
3 answers

R regex can replace opening bracket but not closing bracket

I am trying to replace opening and closing brackets in a string. R seems to do it for the opening bracket: > gsub("[\\[]","==","hello [world]") [1] "hello ==world]" but not for the closing brackets > gsub("[\\]]","==","hello [world]") [1] "hello…
highBandWidth
  • 16,751
  • 20
  • 84
  • 131
4
votes
2 answers

add square brackets in each line of the file using bash

I would like to add square brackets to each and every line of my file. I was using sed -i "s/\(.*\)/[\1]/" file_name.txt command but I see that it is inserting 2 times the square brackets and my output (just the first line and it's the same for…
Sanathana
  • 284
  • 4
  • 16
4
votes
1 answer

What do the square brackets in LaTeX logs mean?

I'm currently working on a parser that reads complete LaTeX logs. Most of the log format is, though weird, easy to figure out, but these square brackets are puzzling me. Here's an example from near the end of one of my logs: Overfull \hbox…
Stefan Majewsky
  • 5,427
  • 2
  • 28
  • 51
4
votes
2 answers

What do square brackets mean in html?

I am assisting on a project right now and building out templates for the first time, trying to wrap my head around a few things but one aspect of the html that's confusing me are certain things sitting in square brackets. I've never used these in…
tganyan
  • 603
  • 3
  • 9
  • 23
4
votes
1 answer

Square brackets around function name

I try to understand delegates at the moment and stumbled across the following snippet: Function [Select](ByVal numbers As List(Of Integer), ByVal filter As Filter) As List(Of Integer) Dim result As New List(Of Integer) For Each number In…
ruedi
  • 5,365
  • 15
  • 52
  • 88
4
votes
5 answers

PHP: Double square brackets after a variable?

echo $a['b']['b2']; What does the value in the brackets refer to? Thanks.
Bobby
  • 242
  • 3
  • 12
4
votes
2 answers

C# regular expression to match square brackets

I'm trying to use a regular expression in C# to match a software version number that can contain: a 2 digit number a 1 or 2 digit number (not starting in 0) another 1 or 2 digit number (not starting in 0) a 1, 2, 3, 4 or 5 digit number (not…
TimCross
  • 91
  • 3
  • 3
  • 7
4
votes
6 answers

Escape [ Square Brackets ] in Fast Report Strings

Good Morning. I am trying to use Fast Reports v1.4.42 Everything was going well up until I attempted to concatenate a string. I am trying to create a string that looks somewhat like the following. 1 - [Name Here] 2 - [Another Name] 3 - [Test Name] I…
Matt Skeldon
  • 577
  • 8
  • 23
4
votes
1 answer

Documentation of squared bracket `[` function

I have a function in R that looks somewhat like this: setMethod('[', signature(x="stack"),definition=function(x,i,j,drop){ new('class', as(x, "SpatialPointsDataFrame")[i,]) }) I use it to get a single element out of a stacked object. For the…
Marco
  • 43
  • 3
3
votes
2 answers

mySQL Regexp with square brackets

I am trying to match strings like '[sometext]' (i.e., left square bracket, text, left angle bracket, text, right angle bracket, right square bracket) within a column in mySQL. Originally I used the following query (notice that since…
Rick
  • 1,863
  • 2
  • 19
  • 46
3
votes
5 answers

Overloading operator[] for a template Polynom class

I am writing a template Polynom class where T is the numeric type of its coefficients. The coefficients of the polynom are stored in an std::vector coefficients, where coefficients[i] corresponds to x^i in a real polynom. (so the powers of x…
wh1t3cat1k
  • 3,146
  • 6
  • 32
  • 38
3
votes
2 answers

C++ Linked List: Overload bracket operators []

So, I decided to look back at some data structures to keep myself sharp ;) I started to implement a hash table, when I remembered that I needed linked lists for the buckets so that I can avoid hash collisions. So I started my linked list... I…
jyore
  • 4,715
  • 2
  • 21
  • 26
1 2
3
18 19