EddTests
EddTests
MModular
Created by sa-code on 9/9/2023 in #questions
Is there an equivalent of PYTHONPATH? I would like to separate my test directory
8 replies
MModular
Created by sa-code on 9/9/2023 in #questions
Is there an equivalent of PYTHONPATH? I would like to separate my test directory
Have you added __init__.mojo files into the src dir?
8 replies
MModular
Created by EddTests on 9/8/2023 in #questions
error: expression must be mutable in assignment
Thanks Jack!
7 replies
MModular
Created by EddTests on 9/8/2023 in #questions
error: expression must be mutable in assignment
I'm running it like
fn main() raises:
print(Fib().generate())
fn main() raises:
print(Fib().generate())
7 replies
MModular
Created by EddTests on 9/8/2023 in #questions
error: expression must be mutable in assignment
So something like this? If so, I'm still seeing some errors:
struct Fib:
var a: Int
var b: Int

fn __init__(inout self):
self.a = 0
self.b = 1

fn generate(inout self) -> Int:
var new_value = self.a + self.b
if self.a > self.b:
self.b = new_value
else:
self.a = new_value

return new_value
struct Fib:
var a: Int
var b: Int

fn __init__(inout self):
self.a = 0
self.b = 1

fn generate(inout self) -> Int:
var new_value = self.a + self.b
if self.a > self.b:
self.b = new_value
else:
self.a = new_value

return new_value
Errors:
@eddtests ➜ /workspaces/mojo-etudes (main) $ mojo ./project-euler/0002.🔥
./project-euler/0002.🔥:22:25: error: invalid call to 'generate': invalid use of mutating method on rvalue of type 'Fib'
print(Fib().generate())
~~~~~~~~~~~~~~^~
./project-euler/0002.🔥:11:5: note: function declared here
fn generate(inout self) -> Int:
^
mojo: error: failed to parse the provided Mojo
@eddtests ➜ /workspaces/mojo-etudes (main) $ mojo ./project-euler/0002.🔥
./project-euler/0002.🔥:22:25: error: invalid call to 'generate': invalid use of mutating method on rvalue of type 'Fib'
print(Fib().generate())
~~~~~~~~~~~~~~^~
./project-euler/0002.🔥:11:5: note: function declared here
fn generate(inout self) -> Int:
^
mojo: error: failed to parse the provided Mojo
O
7 replies