Tag: oop

65 votes
15 answers
1.2K views
Looping through the content of a file in Bash

How do I iterate through each line of a text file with Bash? With this script: echo "Start!" for p in (pepti

avatar
Eddie
0 1 0 9
asked 07 September, 2021
63 votes
6 answers
448 views
How to concat string + i?

for i=1:N f(i) = 'f'+i; end gives an error in MatLab. What's the correct syntax to initial

avatar
Jeff
0 1 0 9
asked 07 September, 2021
59 votes
4 answers
2.6K views
Is MATLAB OOP slow or am I doing something wrong?

I'm experimenting with MATLAB OOP, as a start I mimicked my C++'s Logger classes and I'm puttin

avatar
Benton
0 1 0 9
asked 07 September, 2021
58 votes
20 answers
1.7K views
How do I iterate over a range of numbers defined by variables in Bash?

How do I iterate over a range of numbers in Bash when the range is given by a variable? I know I can do this

avatar
Benton
0 1 0 9
asked 07 September, 2021
59 votes
2 answers
1.2K views
Redux: How do I get Jython to use Python modules stored in Lib within its own jar file when running in Hadoop?

I'm attempting to use Jython for an implementation within Hadoop 1.2.1. I have seen strikingly little ab

avatar
Xavier
0 1 0 9
asked 07 September, 2021
52 votes
2 answers
2.2K views
Why does this Jython loop fail after a single run?

I've got the following code: public static String getVersion() { PythonInterpreter interpreter = ne

avatar
Clarice
0 1 0 9
asked 07 September, 2021
65 votes
7 answers
1.7K views
Understanding Python super() with __init__() methods

I'm trying to understand the use of super(). From the looks of it, both child classes can be created,

avatar
Nidia
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
2.3K views
Difference between staticmethod and classmethod

What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?

avatar
Chaya
0 1 0 9
asked 07 September, 2021
52 votes
23 answers
2.7K views
Accessing the index in 'for' loops?

How do I access the index in a for loop like the following? ints = [8, 23, 45, 12, 78] for i in ints: pri

avatar
Hildegard
0 1 0 9
asked 07 September, 2021
60 votes
23 answers
3.1K views
What are metaclasses in Python?

In Python, what are metaclasses and what do we use them for?

avatar
Boyd
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
1.3K views
Why use getters and setters/accessors?

What's the advantage of using getters and setters - that only get and set - instead of simply using publi

avatar
Shantay
0 1 0 9
asked 07 September, 2021
49 votes
30 answers
2.8K views
How do I break out of nested loops in Java?

I've got a nested loop construct like this: for (Type type : types) { for (Type t : types2) {

avatar
Don
0 1 0 9
asked 07 September, 2021
56 votes
3 answers
1.8K views
Why is printing "B" dramatically slower than printing "#"?

I generated two matrices of 1000 x 1000: First Matrix: O and #. Second Matrix: O and B. Using the following

avatar
Shantay
0 1 0 9
asked 07 September, 2021
56 votes
30 answers
2.2K views
JavaScript closure inside loops – simple practical example

var funcs = []; // let's create 3 functions for (var i = 0; i < 3; i++) { // and store them in f

avatar
Shanita
0 1 0 9
asked 07 September, 2021
63 votes
30 answers
1K views
How do I loop through or enumerate a JavaScript object?

I have a JavaScript object like the following: var p = { "p1": "value1", "p2": "value2", "p3": "v

avatar
Santiago
0 1 0 9
asked 07 September, 2021
58 votes
30 answers
409 views
Loop through an array in JavaScript

In Java you can use a for loop to traverse objects in an array as follows: String[] myStringArray = {"Hello",

avatar
Charis
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
954 views
For-each over an array in JavaScript

How can I loop through all the entries in an array using JavaScript? I thought it was something like this: f

avatar
Cortez
0 1 0 9
asked 07 September, 2021
52 votes
17 answers
1.5K views
What is the difference between public, private, and protected?

When and why should I use public, private, and protected functions and variables inside a class? What is the d

avatar
Nidia
0 1 0 9
asked 07 September, 2021
55 votes
23 answers
1.3K views
When should I use &apos;self&apos; over &apos;$this&apos;?

In PHP 5, what is the difference between using self and $this? When is each appropriate?

avatar
Georgie
0 1 0 9
asked 07 September, 2021
69 votes
7 answers
1.9K views
How does PHP &apos;foreach&apos; actually work?

Let me prefix this by saying that I know what foreach is, does and how to use it. This question concerns how i

avatar
Leonardo
0 1 0 9
asked 07 September, 2021