Questions tagged [parameterized-constructor]
21 questions
7
votes
1 answer
Using role signature in mixins
There seems to be a problem in using the signature given to a role in the roles you want to mix-in. Minimal example:
#!/usr/bin/env perl6
role by-n[$n=1] {
method multiply(Str $str) { return $str x $n; }
}
role by-string[$n=1] does by-n[$n] {
…

jjmerelo
- 22,578
- 8
- 40
- 86
4
votes
1 answer
Julia parametric constructor and incomplete initialization
I'm new to programming in Julia (I'm coming from Java) and some Julia concepts are still difficult to understand to me. What I intend is to replicate this Java code:
public class Archive {
public List solutions;
public…

Antonio
- 41
- 3
4
votes
2 answers
Java Optional.orElseThrow signature explanation
I looked at the Optional class method orElseThrow out of curiosity and I got confused of its signature. I didn't understand why it has to be declared as it is. So, I did an experiment with a copy of the original orElseThrow method and my simplified…

CuriousGuy
- 1,545
- 3
- 20
- 42
3
votes
1 answer
How to change parametric type during instantiation in Julia
I'm trying to do the following
type Foo{T}
x::changeType(T)
end
where the function changeType changes the type parameter to some other type. It doesn't have to be a function, I'm happy using a dictionary or a macro or w/e, I just need a way to…

Set
- 934
- 6
- 25
3
votes
2 answers
Parametrized types in OCaml
I have searched for some time and I can't find a solution. It's probably a simple syntax issue that I can't figure out.
I have a type:
# type ('a, 'b) mytype = 'a * 'b;;
And I want to create a variable of type string string sum.
# let (x:string…

Vlad V
- 1,594
- 1
- 13
- 28
2
votes
2 answers
Instantiating class with interfaces in c#
Hi this might be trivial but I am trying to understand the class instantiation using interface. So below is my code:
public interface IRepository
{
string GetMemberDisplayName();
}
public class Repository : IRepository
{
private readonly…

Naphstor
- 2,356
- 7
- 35
- 53
1
vote
0 answers
Using a constraint with a parmeterized constructor in Spring Boot application
I have a Spring Boot application where an interface has a constraint:
@Constraint(
validatedBy = {
MyValidator.class
})
public @interface MyInterface {
...
}
I'm using Togglz to enable/disable some features and one class where I…

runnerpaul
- 5,942
- 8
- 49
- 118
1
vote
0 answers
Proguard doesn't keep access modifier in parameterized constructor
I have following class A
Class A {
public A(String param1, String param2)
// body
}
public A(String param1, String param2, String param3)
// body
}
}
My proguard settings
keep 'public class com.test.A$* { public…

Galet
- 5,853
- 21
- 82
- 148
1
vote
0 answers
Parameterized MVC6 WebApi constructor not calling using Ninject
I am Using MVC6- WebApi Parameterized constructor not calling. I referenced Ninject the below reference.
http://sudiptachaudhari.com/dependency-injection-aspnet-webapi/
WebApi Controller
public class EmployeeController : ApiController
{
…

Sajith
- 856
- 4
- 19
- 48
1
vote
1 answer
when is it obligatory to define constructors in subclasses?
trying to inherit array adapter class it gives me an error when not defining a constructor in subclass....why should I define a constructor
public class WordAdapter extends ArrayAdapter {
public WordAdapter(Activity context,…
user7516157
1
vote
2 answers
Pytests: getting error function uses no argument error
I have following code:
@pytest.fixture
def mock_path_functions(mocker, file_exists=True, file_size=10):
mock_obj = mock.Mock()
mock_obj.st_size = file_size
mocker.patch("os.path.exists", return_value=file_exists)
…

anish
- 1,035
- 4
- 13
- 27
1
vote
1 answer
NUnit: How can I set name of test depending on parametr in [TestFixture(typeof(param))]
I'm using NUnit + Webdriver + C#. Setup class has next stucture:
[TestFixture(typeof(InternetExplorerDriver))]
[TestFixture(typeof(ChromeDriver))]
public partial class SetupBase where TWebDriver : IWebDriver, new()
{
public…

Tetiana
- 11
- 3
1
vote
2 answers
instantiating parameterized class
Just wondering if this is the right way to do it. I want to construct instances of my parametrized class where one of the instance variables is a generic type. The code below works but I get a lot of warnings in the main method "SomeObject is a raw…

bez
- 177
- 1
- 14
1
vote
9 answers
Any way to call the default constructor from a parameterized constructor?
Suppose, I have the following code
class C {
int i;
String s;
C(){
System.out.println("In main constructor");
// Other processing
}
C(int i){
this(i,"Blank");
System.out.println("In parameterized…

mtk
- 13,221
- 16
- 72
- 112
0
votes
2 answers
Creating a parameterized constructor to determine upper bound for randomized side lengths
Im working on a project for class and we have to create a Triangle class that will hold the lengths of each side of the triangle. I created a default constructor that gives each side of the triangle a random length no more than 6. Were asked to…

Jay Khan
- 5
- 3