Questions tagged [extend]

Cause a unit of code (a class in POO, a style class in CSS ...) to cover a wider area.

Cause a unit of code (a class in POO, a style class in CSS ...) to cover a wider area.

1544 questions
43
votes
11 answers

deep extend (like jQuery's) for nodeJS

I am struggling with deep copies of objects in nodeJS. my own extend is crap. underscore's extend is flat. there are rather simple extend variants here on stackexchange, but none are even close to jQuery.extend(true, {}, obj, obj, obj) .. (most are…
itsatony
  • 987
  • 1
  • 9
  • 13
41
votes
2 answers

Extending an existing jQuery function

I am trying to write a plugin that will extend an existing function in jQuery, e.g. (function($) { $.fn.css = function() { // stuff I will be extending // that doesn't affect/change // the way .css() works …
MacMac
  • 34,294
  • 55
  • 151
  • 222
31
votes
6 answers

Can I extend the console object (for rerouting the logging) in javascript?

Is it possible to extend the console object? I tried something like: Console.prototype.log = function(msg){ Console.prototype.log.call(msg); alert(msg); } But this didn't work. I want to add additional logging to the console object via a…
prefabSOFT
  • 1,143
  • 1
  • 12
  • 23
31
votes
2 answers

Python extend with an empty list bug?

Why does python 2.5.2 have the following behavior >>>[2].extend([]) == [2] False >>> [2].extend([]) == None True $ python --version Python 2.5.2 I assume I'm not understanding something here, but intuitively I'd think that [2].extend([]) should…
Doug T.
  • 64,223
  • 27
  • 138
  • 202
31
votes
6 answers

Can you extend ArrayList in Java?

Is it possible to make a child class that extends ArrayList? If so, how?
nambvarun
  • 1,201
  • 4
  • 13
  • 14
31
votes
9 answers

Is it possible to extend a class dynamically?

I have a class which I need to use to extend different classes (up to hundreds) depending on criteria. Is there a way in PHP to extend a class by a dynamic class name? I assume it would require a method to specify extension with…
Spot
  • 7,962
  • 9
  • 46
  • 55
29
votes
2 answers

User defined __mul__ method is not commutative

I wrote a class to represent vectors in Python (as an exercise) and I'm having problems with extending the built-in operators. I defined a __mul__ method for the vector class. The problem is that in the expression x * y the interpreter calls the…
smackcrane
  • 1,379
  • 2
  • 10
  • 17
29
votes
6 answers

Better way to call superclass method in ExtJS

All the ExtJS documentation and examples I have read suggest calling superclass methods like this: MyApp.MyPanel = Ext.extend(Ext.Panel, { initComponent: function() { // do something MyPanel specific here... …
Rene Saarsoo
  • 13,580
  • 8
  • 57
  • 85
28
votes
2 answers

In Java, can anonymous classes extend another class?

Code like: protected Interface1 varClass1 = new Interface1() { But I would also like that this anonymous nested class also extends the class Base, something like: protected Interface1 varClass1 = new Interface1() extends Base { .... Is this…
user810430
  • 11,181
  • 15
  • 38
  • 43
27
votes
4 answers

Python:Extend the 'dict' class

I have to solve this exercise: Python's dictionaries do not preserve the order of inserted data nor store the data sorted by the key. Write an extension for the dict class whose instances will keep the data sorted by their key value. Note that the…
Sgotenks
  • 1,723
  • 4
  • 20
  • 34
25
votes
2 answers

What is the difference between "include module" and "extend module" in Ruby?

Possible Duplicate: What is the difference between include and extend in Ruby? Given: module my_module def foo ... end end Question 1 What is the difference between: class A include my_module end and class A extend…
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
25
votes
4 answers

How to add a method to an existing class in PHP?

I'm using WordPress as a CMS, and I want to extend one of its classes without having to inherit from another class; i.e. I simply want to "add" more methods to that class: class A { function do_a() { echo 'a'; } } then: function…
Gal
  • 23,122
  • 32
  • 97
  • 118
23
votes
2 answers

How to Inherit or Extend typeDefs in GraphQL

I have a type User. Users can also be a type TeamMember. The only difference between a User and TeamMember is an added field teamRole: String. So, I’d love to do something like the following to avoid having to redundantly define all the user's…
Chris Geirman
  • 9,474
  • 5
  • 37
  • 70
23
votes
5 answers

Putting separate python packages into same namespace?

I'm developing a python framework that would have "addons" written as separate packages. I.e.: import myframework from myframework.addons import foo, bar Now, what I'm trying to arrange is so that these addons can be distributed separately from…
Dimitri Tcaciuc
  • 5,053
  • 5
  • 20
  • 22
22
votes
2 answers

Jinja2: How to use named blocks inside included templates, inside extendable template

I am having the Issue with Jinja2 Extend and Import. base_admin.html
{% include "base_admin_nav.html" %} {% include "base_admin_sidebar.html" %} {%…
Jasim Muhammed
  • 1,376
  • 1
  • 20
  • 28