0

I am new to internet computer. I wrote the following code on Visual Studio:

import Debug "mo:base/Debug";

    actor DBank {
        currentValue = 300;
        currentValue :=100;

        Debug.print(debug_show(currentValue));
    }

I typed, dfx start, to start the server and got the message

May 29 02:03:07.969 INFO Starting server. Listening on http://127.0.0.1:8000/*

And then opened another terminal window and typed, dfx deploy. But the terminal with the server doesn't show the currentValue (of 100) as I expected.

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community May 29 '22 at 21:38

2 Answers2

1

It doesn't show your value due to the fact that canister can not be deployed as there are errors in your code.

You need to first declare your variable currentValue as mutable and declare its type.

For example you can try with this:

import Debug "mo:base/Debug";

actor DBank {
    var currentValue : Int = 300;
    currentValue :=100;
    
    Debug.print(debug_show(currentValue));
    
    let hello : Text = "Hello world";
    Debug.print(debug_show(hello));

}

this should give you output:

[Canister rrkah-fqaaa-aaaaa-aaaaq-cai] +100
[Canister rrkah-fqaaa-aaaaa-aaaaq-cai] "Hello world"
puchal
  • 1,883
  • 13
  • 25
0

You haven't initialized variable properly

import Debug "mo:base/Debug";
actor Dbank{
  var currentValue = 300;
  currentValue := 100;
  Debug.print(debug_show(currentValue));
}