Skip to main content

8 posts tagged with "Programming"

Posts about programming techniques and tools.

View All Tags

Difference between get(), getproperty(), and getfield()

· 3 min read
  1. get
    • Scope:Generally used to retrieve values from indexable data structures (such as Dict, Array) or other containers with customizable interfaces.
    • Functionget(collection, key, default) will attempt to retrieve the value for key from collection. If the value is not found, default will be returned.
    • Example
      d = Dict(:a => 1, :b => 2)
      println(get(d, :a, 0)) # 1
      println(get(d, :c, 0)) # 0 (Due to :c not existing)
    • Application:When there is no guarantee that a key will always exist, you can gracefully provide a default value and avoid throwing an error.

Control Flow

· 3 min read

The for loop

To iterate over the elements within an array, there are several different ways to write the code. Now suppose we have such an array: a = copy(reshape(1:16, 4, 4))

Plot

· 4 min read

PlotlyLight.jl

I really had to write about the PlotlyLight package because it starts up much faster than other plotting packages, both in terms of first run time and first plot time. So how fast is it?