Questions tagged [default-value]

A default, in computer science, refers to a setting or value automatically assigned to a software application, computer program or device, outside of user intervention.

A default, in computer science, refers to a setting or value automatically assigned to a software application, computer program or device, outside of user intervention. Such settings are also called presets, especially for electronic devices. The Oxford English Dictionary dates this usage to the mid-1960s, as a variant of the older meaning of "failure in performance".

Default values are generally intended to make a device (or control) usable "out of the box". A common setting, or at least a usable setting, is typically assigned.

More details : Default (Computer science)

2009 questions
798
votes
15 answers

Collections.defaultdict difference with normal dict

I've read the examples in python docs, but still can't figure out what this method means. Can somebody help? Here are two examples from the python docs >>> from collections import defaultdict >>> s = 'mississippi' >>> d = defaultdict(int) >>> for k…
Lanston
  • 11,354
  • 8
  • 32
  • 37
463
votes
14 answers

How to set a default value for an existing column

This isn't working in SQL Server 2008: ALTER TABLE Employee ALTER COLUMN CityBorn SET DEFAULT 'SANDNES' The error is: Incorrect syntax near the keyword 'SET'. What am I doing wrong?
Nakul Chaudhary
  • 25,572
  • 15
  • 44
  • 47
393
votes
23 answers

Named tuple and default values for optional keyword arguments

I'm trying to convert a longish hollow "data" class into a named tuple. My class currently looks like this: class Node(object): def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right =…
sasuke
  • 6,589
  • 5
  • 36
  • 35
337
votes
12 answers

Initialization of all elements of an array to one default value in C++?

C++ Notes: Array Initialization has a nice list over initialization of arrays. I have a int array[100] = {-1}; expecting it to be full with -1's but its not, only first value is and the rest are 0's mixed with random values. The code int array[100]…
Milan
  • 15,389
  • 20
  • 57
  • 65
323
votes
8 answers

Default value of 'boolean' and 'Boolean' in Java

What are the default values of boolean (primitive) and Boolean (primitive wrapper) in Java?
Makky
  • 17,117
  • 17
  • 63
  • 86
309
votes
2 answers

Python argparse: default value or specified value

I would like to have a optional argument that will default to a value if only the flag is present with no value specified, but store a user-specified value instead of the default if the user specifies a value. Is there already an action available…
Rob
  • 7,377
  • 7
  • 36
  • 38
301
votes
23 answers

Change default text in input type="file"?

I want to change default text on button that is "Choose File" when we use input="file". How can I do this? Also as you can see in image button is on left side of text. How can I put it on right side of text?
Harry Joy
  • 58,650
  • 30
  • 162
  • 207
279
votes
26 answers

How to populate/instantiate a C# array with a single value?

I know that instantiated arrays of value types in C# are automatically populated with the default value of the type (e.g. false for bool, 0 for int, etc.). Is there a way to auto-populate an array with a seed value that's not the default? Either on…
patjbs
  • 4,522
  • 3
  • 23
  • 18
264
votes
18 answers

Entity Framework 6 Code first Default value

is there "elegant" way to give specific property a default value ? Maybe by DataAnnotations, something like : [DefaultValue("true")] public bool Active { get; set; } Thank you.
marino-krk
  • 2,651
  • 3
  • 13
  • 5
262
votes
9 answers

How to set default values in Go structs

There are multiple answers/techniques to the below question: How to set default values to golang structs? How to initialize structs in golang I have a couple of answers but further discussion is required.
Prateek
  • 6,644
  • 6
  • 22
  • 26
240
votes
15 answers

Why is the default value of the string type null instead of an empty string?

It's quite annoying to test all my strings for null before I can safely apply methods like ToUpper(), StartWith() etc... If the default value of string were the empty string, I would not have to test, and I would feel it to be more consistent with…
Marcel
  • 15,039
  • 20
  • 92
  • 150
229
votes
4 answers

Default value in Go's method

Is there a way to specify default value in Go's function? I am trying to find this in the documentation but I can't find anything that specifies that this is even possible. func SaySomething(i string = "Hello")(string){ ... }
denniss
  • 17,229
  • 26
  • 92
  • 141
218
votes
10 answers

Why can't a text column have a default value in MySQL?

If you try to create a TEXT column on a table, and give it a default value in MySQL, you get an error (on Windows at least). I cannot see any reason why a text column should not have a default value. No explanation is given by the MySQL…
Russ
  • 3,768
  • 7
  • 28
  • 37
185
votes
25 answers

How to set a default value in react-select

I have an issue using react-select. I use redux form and I've made my react-select component compatible with redux form. Here is the code: const MySelect = props => (