Questions tagged [dynamic]

Dynamic is a widely used term that, in general, describes a decision made by the program at run-time rather than at compile time.

Programs that perform some common tasks based on program inputs in contrast with programs that predetermine the task beforehand. Dynamic is often used to mean:

  • The dynamic keyword
  • using JavaScript to manipulate web pages in the browser.
  • have features that allow the of a variable to be bound at run-time.
  • Program generated content, especially content in contrast with web pages created by a person and stored on disk, ready to serve.
27209 questions
3456
votes
24 answers

What is the difference between call and apply?

What is the difference between using Function.prototype.apply() and Function.prototype.call() to invoke a function? const func = function() { alert("Hello world!"); }; func.apply() vs. func.call() Are there performance differences between the…
John Duff
  • 38,090
  • 5
  • 35
  • 45
1176
votes
32 answers

Deserialize JSON into C# dynamic object?

Is there a way to deserialize JSON content into a C# dynamic type? It would be nice to skip creating a bunch of classes in order to use the DataContractJsonSerializer.
jswanson
  • 16,244
  • 6
  • 20
  • 15
565
votes
3 answers

What's the difference between eval, exec, and compile?

I've been looking at dynamic evaluation of Python code, and come across the eval() and compile() functions, and the exec statement. Can someone please explain the difference between eval and exec, and how the different modes of compile() fit in?
andrewdotnich
  • 16,195
  • 7
  • 38
  • 57
346
votes
7 answers

How do you dynamically add elements to a ListView on Android?

Can anyone explain or suggest a tutorial to dynamically create a ListView in android? Here are my requirements: I should be able to dynamically add new elements by pressing a button. Should be simple enough to understand (possibly without any…
user555217
  • 3,477
  • 3
  • 15
  • 3
332
votes
5 answers

Are parameters in strings.xml possible?

In my Android app I'am going to implement my strings with internationalization. I have a problem with the grammar and the way sentences build in different languages. For example: "5 minutes ago" - English "vor 5 Minuten" - German Can I do…
dhesse
  • 3,610
  • 2
  • 20
  • 12
294
votes
5 answers

Dynamically adding properties to an ExpandoObject

I would like to dynamically add properties to a ExpandoObject at runtime. So for example to add a string property call NewProp I would like to write something like var x = new ExpandoObject(); x.AddProperty("NewProp", System.String); Is this easily…
Craig
  • 36,306
  • 34
  • 114
  • 197
290
votes
20 answers

Dynamic variable names in Bash

I am confused about a bash script. I have the following code: function grep_search() { magic_way_to_define_magic_variable_$1=`ls | tail -1` echo $magic_variable_$1 } I want to be able to create a variable name containing the first argument…
Konstantinos
  • 4,096
  • 3
  • 19
  • 28
276
votes
10 answers

What is the 'dynamic' type in C# 4.0 used for?

C# 4.0 introduced a new type called 'dynamic'. It all sounds good, but what would a programmer use it for? Is there a situation where it can save the day?
Fahad
  • 2,903
  • 3
  • 18
  • 13
264
votes
15 answers

Test if a property is available on a dynamic variable

My situation is very simple. Somewhere in my code I have this: dynamic myVariable = GetDataThatLooksVerySimilarButNotTheSame(); //How to do this? if (myVariable.MyProperty.Exists) //Do stuff So, basically my question is how to check (without…
roundcrisis
  • 17,276
  • 14
  • 60
  • 92
241
votes
2 answers

Rendering Angular components in Handsontable Cells

In a project of mine, I try to display Angular Components (like an Autocomplete Dropdown Search) in a table. Because of the requirements I have (like multi-selecting different cells with ctrl+click) I decided to give it a go with handsontable. I've…
phhbr
  • 2,699
  • 1
  • 14
  • 25
231
votes
15 answers

Get value of c# dynamic property via string

I'd like to access the value of a dynamic c# property with a string: dynamic d = new { value1 = "some", value2 = "random", value3 = "value" }; How can I get the value of d.value2 ("random") if I only have "value2" as a string? In javascript, I could…
TimDog
  • 8,758
  • 5
  • 41
  • 50
228
votes
9 answers

Using braces with dynamic variable names in PHP

I'm trying to use dynamic variable names (I'm not sure what they're actually called) But pretty much like this: for($i=0; $i<=2; $i++) { $("file" . $i) = file($filelist[$i]); } var_dump($file0); The return is null which tells me it's not…
user1159454
  • 3,267
  • 3
  • 19
  • 25
219
votes
11 answers

How to implement a rule engine?

I have a db table that stores the following: RuleID objectProperty ComparisonOperator TargetValue 1 age 'greater_than' 15 2 username 'equal' 'some_name' 3 tags 'hasAtLeastOne' …
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
214
votes
10 answers

How to perform runtime type checking in Dart?

Dart specification states: Reified type information reflects the types of objects at runtime and may always be queried by dynamic typechecking constructs (the analogs of instanceOf, casts, typecase etc. in other languages). Sounds great, but…
Volo
  • 28,673
  • 12
  • 97
  • 125
213
votes
14 answers

What's the difference between dynamic (C# 4) and var?

I had read a ton of articles about that new keyword that is shipping with C# v4, but I couldn't make out the difference between a "dynamic" and "var". This article made me think about it, but I still can't see any difference. Is it that you can use…
Ivan Prodanov
  • 34,634
  • 78
  • 176
  • 248
1
2 3
99 100